[cloud] ec2.py: add region to the aws_connect_kwargs before creating vpc connection Fixes #25673 (#25749)

* add region to the aws_connect_kwargs before creating vpc connection

* remove unused import
pull/25772/head
Sloane Hertel 8 years ago committed by Ryan Brown
parent 540e1bbd69
commit 938d60472a

@ -1642,12 +1642,15 @@ def main():
module.fail_json(msg='boto required for this module') module.fail_json(msg='boto required for this module')
try: try:
_, ec2_url, aws_connect_kwargs = get_aws_connection_info(module) region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module)
if module.params.get('region') or not module.params.get('ec2_url'): if module.params.get('region') or not module.params.get('ec2_url'):
ec2 = ec2_connect(module) ec2 = ec2_connect(module)
elif module.params.get('ec2_url'): elif module.params.get('ec2_url'):
ec2 = connect_ec2_endpoint(ec2_url, **aws_connect_kwargs) ec2 = connect_ec2_endpoint(ec2_url, **aws_connect_kwargs)
if 'region' not in aws_connect_kwargs:
aws_connect_kwargs['region'] = ec2.region
vpc = connect_vpc(**aws_connect_kwargs) vpc = connect_vpc(**aws_connect_kwargs)
except boto.exception.NoAuthHandlerFound as e: except boto.exception.NoAuthHandlerFound as e:
module.fail_json(msg="Failed to get connection: %s" % e.message, exception=traceback.format_exc()) module.fail_json(msg="Failed to get connection: %s" % e.message, exception=traceback.format_exc())

Loading…
Cancel
Save