Skip to content

Commit

Permalink
Merge branch 'hotfix/0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Dahlgren committed Jun 25, 2014
2 parents 4b90a08 + f67f716 commit 5e1d3b6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ You can also restart it using
Release notes
-------------

0.3.1
^^^^^

- Fixed IAM Instance Profile authentication for boto >= 2.29.0 (`#6 <https://github.com/skymill/automated-ebs-snapshots/issues/6>`__)

0.3.0
^^^^^

Expand Down
20 changes: 8 additions & 12 deletions automated_ebs_snapshots/connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,21 @@ def connect_to_ec2(region='us-east-1', access_key=None, secret_key=None):
"""
logger.info('Connecting to AWS EC2 in {}'.format(region))

# Fetch instance metadata
metadata = get_instance_metadata(timeout=1, num_retries=1)
if metadata:
try:
profile_name = metadata['iam']['info'][u'InstanceProfileArn']
region = metadata['placement']['availability-zone'][:-1]
except KeyError:
profile_name = None

if access_key:
# Connect using supplied credentials
connection = ec2.connect_to_region(
region,
aws_access_key_id=access_key,
aws_secret_access_key=secret_key)
elif metadata:
# Connect using instance profile
connection = ec2.connect_to_region(region, profile_name=profile_name)
else:
# Fetch instance metadata
metadata = get_instance_metadata(timeout=1, num_retries=1)
if metadata:
try:
region = metadata['placement']['availability-zone'][:-1]
except KeyError:
pass

# Connect using env vars or boto credentials
connection = ec2.connect_to_region(region)

Expand Down
2 changes: 1 addition & 1 deletion automated_ebs_snapshots/settings.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[general]
version: 0.3.0
version: 0.3.1

0 comments on commit 5e1d3b6

Please sign in to comment.