Created
March 3, 2016 19:26
-
-
Save clebio/6183865285042f04beb2 to your computer and use it in GitHub Desktop.
S3 using IAM roles for EC2
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/env python | |
from boto import connect_s3 | |
import argparse | |
parser = argparse.ArgumentParser(description="Read file names and S3 bucket path") | |
parser.add_argument('bucket_name', type=str, help='Name of the S3 bucket to connect to.') | |
parser.add_argument('file_path', type=str, help='path to a file on S3') | |
args = parser.parse_args() | |
s3 = connect_s3() | |
bucket = s3.get_bucket(args.bucket_name) | |
key = bucket.get_key(args.file_path) | |
key.get_contents_to_filename(key.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment