From e0ab101f57a3bfbd3b4e55be6825e34afc450a0f Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:27:54 +0000 Subject: [PATCH] ec2_vpc_nat_gateway - catch extra error code for invalid elastic IP Id (#2418) (#2422) This is a backport of PR #2418 as merged into main (b9a5127). SUMMARY Closes #1872 ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_vpc_nat_gateway Reviewed-by: Bikouo Aubin --- ...0241206-ec2_nat_gateway-retry-on-invalid-elastic-ip-id.yaml | 3 +++ plugins/module_utils/ec2.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/20241206-ec2_nat_gateway-retry-on-invalid-elastic-ip-id.yaml diff --git a/changelogs/fragments/20241206-ec2_nat_gateway-retry-on-invalid-elastic-ip-id.yaml b/changelogs/fragments/20241206-ec2_nat_gateway-retry-on-invalid-elastic-ip-id.yaml new file mode 100644 index 00000000000..2fa96054fbe --- /dev/null +++ b/changelogs/fragments/20241206-ec2_nat_gateway-retry-on-invalid-elastic-ip-id.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - module_utils/ec2 - catch error code ``InvalidElasticIpID.NotFound`` on function ``create_nat_gateway()``, sometimes the ``allocate_address`` API calls will return the ID for a new elastic IP resource before it can be consistently referenced (https://github.com/ansible-collections/amazon.aws/issues/1872). \ No newline at end of file diff --git a/plugins/module_utils/ec2.py b/plugins/module_utils/ec2.py index 0dd15e41ff7..4490044bb12 100644 --- a/plugins/module_utils/ec2.py +++ b/plugins/module_utils/ec2.py @@ -482,7 +482,7 @@ def delete_nat_gateway(client, nat_gateway_id: str) -> bool: @EC2NatGatewayErrorHandler.common_error_handler("create nat gateway") -@AWSRetry.jittered_backoff() +@AWSRetry.jittered_backoff(catch_extra_error_codes=["InvalidElasticIpID.NotFound"]) def create_nat_gateway( client, **params: Dict[str, Union[str, bool, int, EC2TagSpecifications, List[str]]] ) -> Dict[str, Any]: