Skip to content

Commit

Permalink
Retry getting initial details of subnet when waiting if we're not pas…
Browse files Browse the repository at this point in the history
…sed any
  • Loading branch information
tremble committed May 7, 2023
1 parent 18de7de commit 7cc5867
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/fstring-ec2_inv.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 1483 includes a fragment and links to 1513
trivial:
- bulk migration of ``%`` and ``.format()`` to fstrings (https://github.com/ansible-collections/amazon.aws/pull/1526).
minor_changes:
- ec2_vpc_subnet - retry fetching subnet details after creation if the first attempt fails (https://github.com/ansible-collections/amazon.aws/pull/1526).
4 changes: 4 additions & 0 deletions plugins/modules/ec2_vpc_subnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@ def ensure_subnet_present(conn, module):

subnet = get_matching_subnet(conn, module, module.params["vpc_id"], module.params["cidr"])
if not module.check_mode and module.params["wait"]:
for _rewait in range(0, 5):
break if subnet
time.sleep(2)
subnet = get_matching_subnet(conn, module, module.params["vpc_id"], module.params["cidr"])
# GET calls are not monotonic for map_public_ip_on_launch and assign_ipv6_address_on_creation
# so we only wait for those if necessary just before returning the subnet
subnet = ensure_final_subnet(conn, module, subnet, start_time)
Expand Down

0 comments on commit 7cc5867

Please sign in to comment.