How To Generate Signed URLs

Amazon S3

Using Python

We will use Python along with the Boto3 SDK to generate the Signed URLS that are to be uploaded to Labelbox. The signed URLs can be generated in Python using the Boto SDK. Boto is the Amazon Web Services (AWS) SDK for Python, which allows Python developers to write software that makes use of Amazon services like S3 and EC2.


Before you can begin using Boto 3, you should set up authentication credentials. Credentials for your AWS account can be found in the IAM Console. You can create or use an existing user. Go to manage access keys and generate a new set of keys.

If you have the AWS CLI installed, then you can use it to configure your credentials file:

aws configure

Alternatively, you can create the credential file yourself. By default, its location is at ~/.aws/credentials:

[default] aws_access_key_id = YOUR_ACCESS_KEY aws_secret_access_key = YOUR_SECRET_KEY

  • Install Boto3 pip install boto3
Using Boto3

The Python script below gets all the objects in a chosen bucket and generates the Signed URLs for each object, then prints them to the screen.

import boto3

s3 = boto3.resource('s3')
s3_client = boto3.client('s3')

#Your Bucket Name
bucket = s3.Bucket('YOUR_BUCKET_NAME')

#Gets the list of objects in the Bucket
s3_Bucket_iterator = bucket.objects.all()

#IGenerates the Signed URL for each object in the Bucket
for i in s3_Bucket_iterator:
url = s3_client.generate_presigned_url(ClientMethod='get_object',Params={'Bucket','Key':i.key})

For more information and a detailed guide on Boto click here. For more information on Signed URLs in Amazon S3 click here.

How did we do?