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_igw: fix 'NoneType' object is not subscriptable #691

Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions changelogs/fragments/691-ec2_vpc_igw-fix-null-igw-error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- ec2_vpc_igw - fix 'NoneType' object is not subscriptable error (https://github.com/ansible-collections/amazon.aws/pull/691)
jatorcasso marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 7 additions & 0 deletions plugins/modules/ec2_vpc_igw.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
from ..module_utils.ec2 import ensure_ec2_tags
from ..module_utils.ec2 import ansible_dict_to_boto3_filter_list
from ..module_utils.tagging import boto3_tag_list_to_ansible_dict
from time import sleep


class AnsibleEc2Igw():
Expand Down Expand Up @@ -207,6 +208,7 @@ def ensure_igw_present(self, vpc_id, tags, purge_tags):
InternetGatewayId=igw['internet_gateway_id'],
VpcId=vpc_id
)
sleep(5)
self._results['changed'] = True
except botocore.exceptions.WaiterError as e:
self._module.fail_json_aws(e, msg="No Internet Gateway exists.")
Expand All @@ -218,6 +220,11 @@ def ensure_igw_present(self, vpc_id, tags, purge_tags):
resource_type='internet-gateway', tags=tags, purge_tags=purge_tags
)
igw = self.get_matching_igw(vpc_id)

if igw is None:
self._module.fail_json(
msg='EC2 could not find an Internet Gateway attached to VPC {0}, aborting'.format(vpc_id))

jatorcasso marked this conversation as resolved.
Show resolved Hide resolved
igw_info = self.get_igw_info(igw, vpc_id)
self._results.update(igw_info)

Expand Down