summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <bcoca@ansible.com>2014-12-22 08:46:20 -0500
committerBrian Coca <bcoca@ansible.com>2014-12-22 08:46:20 -0500
commit19038a71bfc4ad3630991e14b21692b20cf611fa (patch)
tree104fdbf6e7397a8585ac6299d4b03a186ca72328
parentcefe0974d90957900de6f86ca8023ca80ebdaabc (diff)
parent2397926b948ec827bef4debb108b7806a7a039f1 (diff)
downloadansible-19038a71bfc4ad3630991e14b21692b20cf611fa.tar.gz
Merge pull request #9419 from willthames/aws_frankfurt
There are still a couple of modules that use their own lists, but that should not prevent this merge, those should be adapted to use this list in subsequent patch
-rw-r--r--lib/ansible/module_utils/ec2.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/ansible/module_utils/ec2.py b/lib/ansible/module_utils/ec2.py
index 417e1b9521..0f08fead18 100644
--- a/lib/ansible/module_utils/ec2.py
+++ b/lib/ansible/module_utils/ec2.py
@@ -39,6 +39,7 @@ AWS_REGIONS = [
'cn-north-1',
'eu-central-1',
'eu-west-1',
+ 'eu-central-1',
'sa-east-1',
'us-east-1',
'us-west-1',
@@ -165,6 +166,11 @@ def boto_fix_security_token_in_profile(conn, profile_name):
def connect_to_aws(aws_module, region, **params):
conn = aws_module.connect_to_region(region, **params)
+ if not conn:
+ if region not in [aws_module_region.name for aws_module_region in aws_module.regions()]:
+ raise StandardError("Region %s does not seem to be available for aws module %s. If the region definitely exists, you may need to upgrade boto" % (region, aws_module.__name__))
+ else:
+ raise StandardError("Unknown problem connecting to region %s for aws module %s." % (region, aws_module.__name__))
if params.get('profile_name'):
conn = boto_fix_security_token_in_profile(conn, params['profile_name'])
return conn
@@ -180,13 +186,13 @@ def ec2_connect(module):
if region:
try:
ec2 = connect_to_aws(boto.ec2, region, **boto_params)
- except boto.exception.NoAuthHandlerFound, e:
+ except (boto.exception.NoAuthHandlerFound, StandardError), e:
module.fail_json(msg=str(e))
# Otherwise, no region so we fallback to the old connection method
elif ec2_url:
try:
ec2 = boto.connect_ec2_endpoint(ec2_url, **boto_params)
- except boto.exception.NoAuthHandlerFound, e:
+ except (boto.exception.NoAuthHandlerFound, StandardError), e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="Either region or ec2_url must be specified")