From 69d81d54b8cba18eaeeec3189d2baea5c262db27 Mon Sep 17 00:00:00 2001 From: Mike Graves Date: Mon, 11 Nov 2024 10:08:29 -0500 Subject: [PATCH] Ec2 transit gateway empty description (#2375) SUMMARY When one or more TGWs exist with an empty description, the module will fail. Fixes #2368 ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_transit_gateway ADDITIONAL INFORMATION Apparently, ansible-collections/community.aws#2086 failed to merge, and the ec2_transit_gateway module has now been migrated to amazon.aws. This PR just cherry-picks the commits on top of this repo. Reviewed-by: Alina Buzachis Reviewed-by: GomathiselviS --- changelogs/fragments/fix_tgw_description.yml | 2 ++ plugins/modules/ec2_transit_gateway.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/fix_tgw_description.yml 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 f2dbd118f95..23859f6234d 100644 --- a/plugins/modules/ec2_transit_gateway.py +++ b/plugins/modules/ec2_transit_gateway.py @@ -306,7 +306,7 @@ def get_matching_tgw( tgws.extend(response) for gateway in response: - if description == gateway["Description"] and gateway["State"] != "deleted": + if description == gateway.get("Description", "") and gateway["State"] != "deleted": tgws.append(gateway) if len(tgws) > 1: