Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for authenticating with env vars #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Usage
1. Install and configure Python and Boto (See: https://github.com/boto/boto)
2. Create a SNS topic in AWS and copy the ARN into the config file
3. Subscribe with a email address to the SNS topic
4. Create a snapshot user in IAM and put the key and secret in the config file
4. Create a snapshot user in IAM and put the key and secret in the config file (or set them as [environment variables](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment))
5. Create a security policy for this user (see the iam.policy.sample)
6. Copy config.sample to config.py
7. Decide how many versions of the snapshots you want for day/week/month and change this in config.py
Expand Down
11 changes: 9 additions & 2 deletions makesnapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import sys
import logging
from config import config
from os import environ


if (len(sys.argv) < 2):
Expand Down Expand Up @@ -69,8 +70,14 @@
logging.info(start_message)

# Get settings from config.py
aws_access_key = config['aws_access_key']
aws_secret_key = config['aws_secret_key']
try:
# Try to load user-specified access keys from environment variables
aws_access_key = environ['AWS_ACCESS_KEY_ID']
aws_secret_key = environ['AWS_SECRET_ACCESS_KEY']
except:
# Or from the config file (if ENV don't exist)
aws_access_key = config['aws_access_key']
aws_secret_key = config['aws_secret_key']
ec2_region_name = config['ec2_region_name']
ec2_region_endpoint = config['ec2_region_endpoint']
sns_arn = config.get('arn')
Expand Down