mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Allow ec2_vpc_net to work in non classiclink regions (#34336)
describe_vpc_classic_link only works in regions that support EC2-Classic.
This commit is contained in:
parent
b40c779e46
commit
1412d6eb18
1 changed files with 9 additions and 1 deletions
|
@ -196,9 +196,17 @@ def vpc_exists(module, vpc, name, cidr_block, multi):
|
|||
def get_vpc(module, connection, vpc_id):
|
||||
try:
|
||||
vpc_obj = connection.describe_vpcs(VpcIds=[vpc_id])['Vpcs'][0]
|
||||
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
|
||||
module.fail_json_aws(e, msg="Failed to describe VPCs")
|
||||
try:
|
||||
classic_link = connection.describe_vpc_classic_link(VpcIds=[vpc_id])['Vpcs'][0].get('ClassicLinkEnabled')
|
||||
vpc_obj['ClassicLinkEnabled'] = classic_link
|
||||
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
|
||||
except botocore.exceptions.ClientError as e:
|
||||
if e.response["Error"]["Message"] == "The functionality you requested is not available in this region.":
|
||||
vpc_obj['ClassicLinkEnabled'] = False
|
||||
else:
|
||||
module.fail_json_aws(e, msg="Failed to describe VPCs")
|
||||
except botocore.exceptions.BotoCoreError as e:
|
||||
module.fail_json_aws(e, msg="Failed to describe VPCs")
|
||||
|
||||
return vpc_obj
|
||||
|
|
Loading…
Reference in a new issue