From 38b0eb33f0c37f533583daf93e3703257b301a64 Mon Sep 17 00:00:00 2001 From: aubin bikouo Date: Mon, 9 Dec 2024 11:36:49 +0100 Subject: [PATCH] ec2_vpc_nat_gateway - catch extra error code for invalid elastic IP Id --- ...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]: