Skip to content

Commit

Permalink
fix delete records without TTL (ansible-collections#801)
Browse files Browse the repository at this point in the history
fix delete records without TTL

SUMMARY
Closes ansible-collections#800
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
route53

Reviewed-by: Mark Chappell <None>
Reviewed-by: Felix Fontein <None>
Reviewed-by: Tiger Kaovilai <[email protected]>
Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: None <None>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@472776e
  • Loading branch information
markuman authored and goneri committed Sep 21, 2022
1 parent 5dc5e30 commit ffd0336
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugins/modules/route53.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
value:
description:
- The new value when creating a DNS record. YAML lists or multiple comma-spaced values are allowed for non-alias records.
- When deleting a record all values for the record must be specified or Route 53 will not delete it.
type: list
elements: str
overwrite:
Expand Down Expand Up @@ -513,8 +512,6 @@ def main():
required_if=(
('state', 'present', ['value']),
('state', 'create', ['value']),
('state', 'absent', ['value']),
('state', 'delete', ['value']),
),
# failover, region and weight are mutually exclusive
mutually_exclusive=[
Expand Down Expand Up @@ -607,6 +604,10 @@ def main():
'HealthCheckId': health_check_in,
'SetIdentifier': identifier_in,
})
if command_in == 'delete' and aws_record is not None:
resource_record_set['TTL'] = aws_record.get('TTL')
if not resource_record_set['ResourceRecords']:
resource_record_set['ResourceRecords'] = aws_record.get('ResourceRecords')

if alias_in:
resource_record_set['AliasTarget'] = dict(
Expand Down
39 changes: 39 additions & 0 deletions tests/integration/targets/route53/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,45 @@
- wc_a_record is changed
- wc_a_record.diff.after == {}

- name: create a record with different TTL
community.aws.route53:
state: present
zone: '{{ zone_one }}'
record: 'localhost.{{ zone_one }}'
type: A
value: 127.0.0.1
ttl: 30
register: ttl30
- name: check return values
assert:
that:
- ttl30.diff.resource_record_sets[0].ttl == 30
- ttl30 is changed

- name: delete previous record without mention ttl and value
community.aws.route53:
state: absent
zone: '{{ zone_one }}'
record: 'localhost.{{ zone_one }}'
type: A
register: ttl30
- name: check if record is deleted
assert:
that:
- ttl30 is changed

- name: immutable delete previous record without mention ttl and value
community.aws.route53:
state: absent
zone: '{{ zone_one }}'
record: 'localhost.{{ zone_one }}'
type: A
register: ttl30
- name: check if record was deleted
assert:
that:
- ttl30 is not changed

# Tests on zone two (private zone)
- name: Create A record using zone fqdn
route53:
Expand Down

0 comments on commit ffd0336

Please sign in to comment.