Created
April 16, 2015 04:51
-
-
Save sukrit007/4f63b3ca2ea085f4013f to your computer and use it in GitHub Desktop.
AWS S3 Signed URL Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Credits to @isleshocky77 @joech4n
See aws/aws-cli#462