From b9a512702556c02d01748f43b258eef74a9ad238 Mon Sep 17 00:00:00 2001 From: Bikouo Aubin <79859644+abikouo@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:52:51 +0100 Subject: [PATCH] ec2_vpc_nat_gateway - catch extra error code for invalid elastic IP Id (#2418) SUMMARY Closes #1872 ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_vpc_nat_gateway Reviewed-by: Alina Buzachis Reviewed-by: GomathiselviS --- ...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]: