Closed kaovilai closed 2 years ago
Solution would be to make TTL nullable.. and if null.. don't provide TTL in the request.
I can confirm.
Basically when deleting records, the name and type are sufficient. Everything else does not matter. That's how community.dns
is handling it imo.
However, just leaving it out makes botocore fail
"msg": "Failed to update records: An error occurred (InvalidInput) when calling the ChangeResourceRecordSets operation: Invalid request: Expected exactly one of [AliasTarget, all of [TTL, and ResourceRecords], or TrafficPolicyInstanceId], but found none in Change with [Action=DELETE, Name=ansible.xn--mitlinuxwrdasnichtpassiert-ohc.de., Type=A, SetIdentifier=null]",
So we must keep the TTL of the existing record.
This is kind of a hotfix. But I need to make some more tests later.
diff --git a/plugins/modules/route53.py b/plugins/modules/route53.py
index 9640202..e971e18 100644
--- a/plugins/modules/route53.py
+++ b/plugins/modules/route53.py
@@ -596,17 +596,29 @@ def main():
aws_record = get_record(route53, zone_id, record_in, type_in, identifier_in)
- resource_record_set = scrub_none_parameters({
- 'Name': record_in,
- 'Type': type_in,
- 'Weight': weight_in,
- 'Region': region_in,
- 'Failover': failover_in,
- 'TTL': ttl_in,
- 'ResourceRecords': [dict(Value=value) for value in value_in],
- 'HealthCheckId': health_check_in,
- 'SetIdentifier': identifier_in,
- })
+ if command_in is not 'delete':
+ resource_record_set = scrub_none_parameters({
+ 'Name': record_in,
+ 'Type': type_in,
+ 'Weight': weight_in,
+ 'Region': region_in,
+ 'Failover': failover_in,
+ 'TTL': ttl_in,
+ 'ResourceRecords': [dict(Value=value) for value in value_in],
+ 'HealthCheckId': health_check_in,
+ 'SetIdentifier': identifier_in,
+ })
+ else:
+ resource_record_set = scrub_none_parameters({
+ 'Name': record_in,
+ 'Type': type_in,
+ 'Weight': weight_in,
+ 'Region': region_in,
+ 'Failover': failover_in,
+ 'ResourceRecords': [dict(Value=value) for value in value_in],
+ 'HealthCheckId': health_check_in,
+ 'TTL': aws_record.get('TTL')
+ })
if alias_in:
resource_record_set['AliasTarget'] = dict(
Summary
Cannot delete A record without or with TTL value Providing TTL=null results in
When not providing TTL, module uses default of 3600 Providing default ttl result in
Relevant blogs: https://blog.ryanhalliday.com/2019/09/route53-aliastarget-invalid-request.html
Issue Type
Bug Report
Component Name
route53
Ansible Version
Collection Versions
AWS SDK versions
Configuration
OS / Environment
macos
Steps to Reproduce
or leave empty ttl.. results in default ttl 3600 used
Expected Results
A record is deleted without TTL errors
Actual Results
ttl = null
ttl left to default
Code of Conduct