Allow ec2_vpc_net to work in non classiclink regions (#34336)

describe_vpc_classic_link only works in regions that support
EC2-Classic.
pull/34461/head
Will Thames 7 years ago committed by Ryan Brown
parent b40c779e46
commit 1412d6eb18

@ -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…
Cancel
Save