Skip to content

Instantly share code, notes, and snippets.

@sukrit007
Created April 16, 2015 04:51
Show Gist options
  • Save sukrit007/4f63b3ca2ea085f4013f to your computer and use it in GitHub Desktop.
Save sukrit007/4f63b3ca2ea085f4013f to your computer and use it in GitHub Desktop.
AWS S3 Signed URL Script
#!/usr/bin/python
import boto
import argparse
parser = argparse.ArgumentParser(description='Generate an S3 signed URL')
parser.add_argument('-b', '--bucket', help='bucket name')
parser.add_argument('-k', '--key', help='prefix/key')
parser.add_argument('-s', '--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 bucket.get_key(args.key):
print key.generate_url(args.seconds)
else:
print 's3://' + args.bucket + '/' + args.key + ' does not exist'
@sukrit007
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment