diff --git a/changelogs/fragments/fix_tgw_description.yml b/changelogs/fragments/fix_tgw_description.yml new file mode 100644 index 00000000000..e1bfea0a101 --- /dev/null +++ b/changelogs/fragments/fix_tgw_description.yml @@ -0,0 +1,2 @@ +minor_changes: + - ec2_transit_gateway - handle empty description while deleting transit gateway (https://github.com/ansible-collections/community.aws/pull/2086). diff --git a/plugins/modules/ec2_transit_gateway.py b/plugins/modules/ec2_transit_gateway.py index c3a1079e5c9..61696bcfadd 100644 --- a/plugins/modules/ec2_transit_gateway.py +++ b/plugins/modules/ec2_transit_gateway.py @@ -334,7 +334,7 @@ def get_matching_tgw(self, tgw_id, description=None, skip_deleted=True): tgws.extend(response["TransitGateways"]) for gateway in response.get("TransitGateways", []): - if description == gateway["Description"] and gateway["State"] != "deleted": + if description == gateway.get("Description", "") and gateway["State"] != "deleted": tgws.append(gateway) if len(tgws) > 1: