Skip to content

Instantly share code, notes, and snippets.

@clebio
Created March 3, 2016 19:26
Show Gist options
  • Save clebio/6183865285042f04beb2 to your computer and use it in GitHub Desktop.
Save clebio/6183865285042f04beb2 to your computer and use it in GitHub Desktop.
S3 using IAM roles for EC2
#!/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