Skip to content

Instantly share code, notes, and snippets.

@lizturp
Last active March 29, 2018 14:50
Show Gist options
  • Save lizturp/077e54ea2af0c1742fd43187546477d8 to your computer and use it in GitHub Desktop.
Save lizturp/077e54ea2af0c1742fd43187546477d8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import boto3
import argparse
# Available args:
# Environment
# --env dev, stage or prod
#
# run the script from a command line like so:
# python boto-s3-things.py --env=stage
# Adding this snippet allows you to make the script run for stage vs. prod
# This way, you can test changes to it without messing up what you already have scheduled
parser = argparse.ArgumentParser()
parser.add_argument("--env", default='stage', help='environment to execute script against')
args = parser.parse_args()
env = args.env
#GET A FILE FROM S3
# SET LOCATION
bucket = 'bucket-name-here'
configfilename = 'config.yaml'
configkey = "config-{environment}/adobe-analytics/{file}".format(environment=env, file=configfilename)
# This downloads the file to your working directory
s3 = boto3.resource('s3')
s3.meta.client.download_file(bucket, configkey, configfilename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment