Skip to content

Commit

Permalink
route53: add wait_id return value in case of changes (#1683)
Browse files Browse the repository at this point in the history
route53: add wait_id return value in case of changes

SUMMARY
This allows to wait for changes later on when wait=false is provided to the module.
Will be needed for a new route53_wait module I'll create a PR for soon in community.aws :)
(I'm not sure whether another 5.x.0 feature release is planned; in case it is not I'll update version_added and the backport-5 label needs to be removed.)
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
route53

Reviewed-by: Mark Chappell
  • Loading branch information
felixfontein authored Aug 2, 2023
1 parent 51eeebb commit 983cbe9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1683-route53-wait_id.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- "route53 - add a ``wait_id`` return value when a change is done (https://github.com/ansible-collections/amazon.aws/pull/1683)."
9 changes: 9 additions & 0 deletions plugins/modules/route53.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@
returned: always
type: str
sample: foo.bar.com.
wait_id:
description:
- The wait ID for the applied change. Can be used to wait for the change to propagate later on when I(wait=false).
type: str
returned: when changed
version_added: 6.3.0
"""

EXAMPLES = r"""
Expand Down Expand Up @@ -766,13 +772,15 @@ def main():
else:
command = command_in.upper()

wait_id = None
if not module.check_mode:
try:
change_resource_record_sets = route53.change_resource_record_sets(
aws_retry=True,
HostedZoneId=zone_id,
ChangeBatch=dict(Changes=[dict(Action=command, ResourceRecordSet=resource_record_set)]),
)
wait_id = change_resource_record_sets["ChangeInfo"]["Id"]

if wait_in:
waiter = get_waiter(route53, "resource_record_sets_changed")
Expand Down Expand Up @@ -801,6 +809,7 @@ def main():

module.exit_json(
changed=True,
wait_id=wait_id,
diff=dict(
before=formatted_aws,
after=formatted_record if command_in != "delete" else {},
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/targets/route53/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
that:
- qdn is not failed
- qdn is changed
- "'wait_id' in qdn"
- qdn.wait_id is string

- name: Get A record using "get" method of route53 module
route53:
Expand Down Expand Up @@ -191,6 +193,7 @@
that:
- non_qdn is not failed
- non_qdn is not changed
- "'wait_id' not in non_qdn"

- name: Create A record using zone ID
route53:
Expand Down Expand Up @@ -705,6 +708,8 @@
- create_geo_continent_check_mode is changed
- create_geo_continent_check_mode is not failed
- '"route53:ChangeResourceRecordSets" not in create_geo_continent_check_mode.resource_actions'
- '"wait_id" in create_geo_continent_check_mode'
- create_geo_continent_check_mode.wait_id is none

- name: Create a record with geo_location - continent_code
route53:
Expand Down

0 comments on commit 983cbe9

Please sign in to comment.