Skip to content

Commit

Permalink
Remove 'ResourceRecords' when 'AliasTarget' (ansible-collections#502)
Browse files Browse the repository at this point in the history
* Remove 'ResourceRecords' when 'AliasTarget'

sending a change to the route53 api that includes both an AliasTarget and a ResourceRecord causes the api to return with an error.  removing the ResourceRecord when an AliasTarget is preset allows this module to continue without error

* Cleanup tests and use RFC2602 Domains and RFC5737 CIDRs
* Add integration test for aliases
* Make Alias and TTL mutually exclusive
* Update docs to list region/failover/weight as mutually exclusive.
* changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@8a2a138
  • Loading branch information
notatoad authored and goneri committed Sep 21, 2022
1 parent 1880faa commit 5df7bff
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 62 deletions.
14 changes: 13 additions & 1 deletion plugins/modules/route53.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
ttl:
description:
- The TTL, in second, to give the new record.
- Mutually exclusive with I(alias).
default: 3600
type: int
type:
Expand All @@ -55,6 +56,7 @@
alias:
description:
- Indicates if this is an alias record.
- Mutually exclusive with I(ttl).
- Defaults to C(false).
type: bool
alias_hosted_zone_id:
Expand Down Expand Up @@ -99,13 +101,15 @@
have the same combination of DNS name and type, a value that
determines what portion of traffic for the current resource record set
is routed to the associated location.
- Mutually exclusive with I(region) and I(failover).
type: int
region:
description:
- Latency-based resource record sets only Among resource record sets
that have the same combination of DNS name and type, a value that
determines which region this should be associated with for the
latency-based routing
- Mutually exclusive with I(weight) and I(failover).
type: str
health_check:
description:
Expand All @@ -115,6 +119,7 @@
description:
- Failover resource record sets only. Whether this is the primary or
secondary resource record set. Allowed values are PRIMARY and SECONDARY
- Mutually exclusive with I(weight) and I(region).
type: str
choices: ['SECONDARY', 'PRIMARY']
vpc_id:
Expand Down Expand Up @@ -468,7 +473,10 @@ def main():
('state', 'delete', ['value']),
),
# failover, region and weight are mutually exclusive
mutually_exclusive=[('failover', 'region', 'weight')],
mutually_exclusive=[
('failover', 'region', 'weight'),
('alias', 'ttl'),
],
# failover, region and weight require identifier
required_by=dict(
failover=('identifier',),
Expand Down Expand Up @@ -557,6 +565,10 @@ def main():
DNSName=value_in[0],
EvaluateTargetHealth=alias_evaluate_target_health_in
)
if 'ResourceRecords' in resource_record_set:
del resource_record_set['ResourceRecords']
if 'TTL' in resource_record_set:
del resource_record_set['TTL']

# On CAA records order doesn't matter
if type_in == 'CAA':
Expand Down
Loading

0 comments on commit 5df7bff

Please sign in to comment.