Create AWS S3 Pre-Signed Url’s with Python Boto
29. April 2015

Here it is, a small and simple example on how to created presigned URLs for AWS S3 objects.

import boto
import argparse

parser = argparse.ArgumentParser(description='Generate an S3 signed URL')
parser.add_argument('bucket', help='bucket name')
parser.add_argument('key', help='prefix/key')
parser.add_argument('seconds', type=int, help='time in seconds until the URL will expire')
args = parser.parse_args()

s3 = boto.connect_s3()
bucket = s3.get_bucket(args.bucket)
key = bucket.get_key(args.key)
if key:
  print key.generate_url(args.seconds)
  print 's3://' + args.bucket + '/' + args.key + ' does not exist'


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.