Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ec2_vpc_net_info: fix keyerror #1109

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/1109-ec2_vpc_net_info_keyerror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bugfixes:
- ec2_vpc_net_info - fix KeyError (https://github.com/ansible-collections/amazon.aws/pull/1109).
- ec2_vpc_net_info - remove hardcoded ``ClassicLinkEnabled`` parameter when request for ``ClassicLinkDnsSupported`` failed (https://github.com/ansible-collections/amazon.aws/pull/1109).
6 changes: 3 additions & 3 deletions plugins/modules/ec2_vpc_net_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ def describe_vpcs(connection, module):
cl_dns_support = describe_classic_links(module, connection, vpc['VpcId'], 'ClassicLinkDnsSupported', error_message)
dns_support = describe_vpc_attribute(module, connection, vpc['VpcId'], 'enableDnsSupport', error_message)
dns_hostnames = describe_vpc_attribute(module, connection, vpc['VpcId'], 'enableDnsHostnames', error_message)
if cl_enabled:
if cl_enabled.get('Vpcs')[0].get('ClassicLinkEnabled'):
# loop through the ClassicLink Enabled results and add the value for the correct VPC
for item in cl_enabled['Vpcs']:
if vpc['VpcId'] == item['VpcId']:
vpc['ClassicLinkEnabled'] = item['ClassicLinkEnabled']
if cl_dns_support:
if cl_dns_support.get('Vpcs')[0].get('ClassicLinkEnabled'):
# loop through the ClassicLink DNS support results and add the value for the correct VPC
for item in cl_dns_support['Vpcs']:
if vpc['VpcId'] == item['VpcId']:
Expand Down Expand Up @@ -233,7 +233,7 @@ def describe_classic_links(module, connection, vpc, attribute, error_message):
else:
result = connection.describe_vpc_classic_link_dns_support(VpcIds=[vpc], aws_retry=True)
except is_boto3_error_code('UnsupportedOperation'):
result = {'Vpcs': [{'VpcId': vpc, 'ClassicLinkEnabled': False}]}
result = {'Vpcs': [{'VpcId': vpc]}
except is_boto3_error_code('InvalidVpcID.NotFound'):
module.warn(error_message.format(attribute, vpc))
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: # pylint: disable=duplicate-except
Expand Down