From 660c4f296caa62c907749097a478b6e6dea49767 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 2 Nov 2022 10:50:06 +0000 Subject: [PATCH] Fix broken ec2_vpc_vgw tests (#1579) (#1581) [PR #1579/cea2ab5c backport][stable-5] Fix broken ec2_vpc_vgw tests This is a backport of PR #1579 as merged into main (cea2ab5). SUMMARY The APIs are no longer consistently returning deleted attachments. Accept both the attachment being listed but marked 'deleted', and not being listed. Amazon's APIs used to be very slow to update this, making waiting for it a bad idea. ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_vpc_vgw ADDITIONAL INFORMATION Reviewed-by: Mark Chappell --- .../fragments/1579-ec2_vpc_vgw-deleted.yml | 2 ++ .../targets/ec2_vpc_vgw/tasks/main.yml | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/1579-ec2_vpc_vgw-deleted.yml diff --git a/changelogs/fragments/1579-ec2_vpc_vgw-deleted.yml b/changelogs/fragments/1579-ec2_vpc_vgw-deleted.yml new file mode 100644 index 00000000000..db9e57531b3 --- /dev/null +++ b/changelogs/fragments/1579-ec2_vpc_vgw-deleted.yml @@ -0,0 +1,2 @@ +trivial: +- ec2_vpc_vgw - update integration tests to allow for attachments being removed from the list once deleted (https://github.com/ansible-collections/community.aws/pull/1579). diff --git a/tests/integration/targets/ec2_vpc_vgw/tasks/main.yml b/tests/integration/targets/ec2_vpc_vgw/tasks/main.yml index 0a6f9bacdb7..37bbf5e372d 100644 --- a/tests/integration/targets/ec2_vpc_vgw/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_vgw/tasks/main.yml @@ -105,8 +105,11 @@ - vgw_details.state == 'available' - '"Name" in vgw_details.resource_tags' - vgw_details.resource_tags.Name == vgw_name - - vgw_details.vpc_attachments | length == 2 - - attach_1_description in vgw_details.vpc_attachments + - ( + attach_1_description in vgw_details.vpc_attachments + and + vgw_details.vpc_attachments | length == 2 + ) or ( vgw_details.vpc_attachments | length == 1 ) - attach_2_description in vgw_details.vpc_attachments - name: get VPC VGW facts by Tag @@ -138,8 +141,11 @@ - vgw_details.state == 'available' - '"Name" in vgw_details.resource_tags' - vgw_details.resource_tags.Name == vgw_name - - vgw_details.vpc_attachments | length == 2 - - attach_1_description in vgw_details.vpc_attachments + - ( + attach_1_description in vgw_details.vpc_attachments + and + vgw_details.vpc_attachments | length == 2 + ) or ( vgw_details.vpc_attachments | length == 1 ) - attach_2_description in vgw_details.vpc_attachments # ============================================================ @@ -211,7 +217,7 @@ - name: delete vpn gateway ec2_vpc_vgw: state: absent - vpn_gateway_id: '{{ vgw.vgw.id }}' + vpn_gateway_id: '{{ vgw.vgw.id | default(vgw_id) }}' ignore_errors: yes - name: delete vpc