Open pluto00987 opened 9 months ago
On the surface this seems similar to https://github.com/ansible-collections/amazon.aws/pull/1320 but I don't think it's quite the same issue.
The most likely cause is the AWS APIs being "eventually" consistent (the same as #1320). Sometimes the API calls will return things like the ID for a net-new resource before they can be consistently referenced.
updating the client creation call to something like the following will probably ~fix~ work around the issue:
retry_decorator = AWSRetry.jittered_backoff(
catch_extra_error_codes=["InvalidElasticIpID.NotFound"],
)
client = module.client("ec2", retry_decorator=retry_decorator)
Would you be willing to open a PR?
Summary
Creating a NAT gateway with ec2_vpc_nat_gateway using a dynamically-allocated eIP sometimes fails with a botocore exception InvalidElasticIpID.NotFound. This is despite the fact that the eIPallocation it references (eipalloc-0faae3f7d465f76f9 as per the example traceback below) does exist, at least after the fact, and also that no eIP is provided by the yaml so it is creating that eIP itself (as expected).
It's unclear to me why this happens, ie if it's a collection issue or a boto issue. I don't see any 'state' or similar attribute on an eIP that would suggest it might not be 'ready' as soon as it 'exists'. As such I'm not sure if/how the collection could check for that in between eIP creation and NATgw creation.
This is with aws collection 6.2.0, but I don't see any changes to ec2_vpc_nat_gateway.py in newer versions of 6.x
Issue Type
Bug Report
Component Name
ec2_vpc_nat_gateway
Ansible Version
Collection Versions
AWS SDK versions
Configuration
OS / Environment
CentOS Stream release 9
Steps to Reproduce
Expected Results
This should create a new public NAT gateway, using a freshly-allocated Elastic IP.
Actual Results
Code of Conduct