[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
This commit is contained in:
parent
540e1bbd69
commit
938d60472a
1 changed files with 4 additions and 1 deletions
|
@ -1642,12 +1642,15 @@ def main():
|
|||
module.fail_json(msg='boto required for this module')
|
||||
|
||||
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'):
|
||||
ec2 = ec2_connect(module)
|
||||
elif module.params.get('ec2_url'):
|
||||
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)
|
||||
except boto.exception.NoAuthHandlerFound as e:
|
||||
module.fail_json(msg="Failed to get connection: %s" % e.message, exception=traceback.format_exc())
|
||||
|
|
Loading…
Reference in a new issue