diff --git a/changelogs/fragments/595-fix-route53-identifer.yaml b/changelogs/fragments/595-fix-route53-identifer.yaml new file mode 100644 index 00000000000..11901c1655b --- /dev/null +++ b/changelogs/fragments/595-fix-route53-identifer.yaml @@ -0,0 +1,2 @@ +bugfixes: + - route53 - add missing set identifier in resource_record_set (https://github.com/ansible-collections/community.aws/pull/595). diff --git a/plugins/modules/route53.py b/plugins/modules/route53.py index d1391cfac58..d4fe99531c0 100644 --- a/plugins/modules/route53.py +++ b/plugins/modules/route53.py @@ -606,6 +606,7 @@ def main(): 'TTL': ttl_in, 'ResourceRecords': [dict(Value=value) for value in value_in], 'HealthCheckId': health_check_in, + 'SetIdentifier': identifier_in, }) if alias_in: diff --git a/tests/integration/targets/route53/tasks/main.yml b/tests/integration/targets/route53/tasks/main.yml index 18f10ae2987..ae80586dbe8 100644 --- a/tests/integration/targets/route53/tasks/main.yml +++ b/tests/integration/targets/route53/tasks/main.yml @@ -503,6 +503,42 @@ - alias_record is not failed - alias_record is not changed + - name: 'Create a weighted record' + route53: + state: present + zone: '{{ zone_one }}' + record: 'weighted.{{ zone_one }}' + type: CNAME + value: 'zid_test.{{ zone_one }}' + overwrite: True + identifier: "host1@www" + weight: 100 + region: '{{ omit }}' + register: weighted_record + - name: 'This should be changed' + assert: + that: + - weighted_record is not failed + - weighted_record is changed + + - name: 'Re-Create a weighted record' + route53: + state: present + zone: '{{ zone_one }}' + record: 'weighted.{{ zone_one }}' + type: CNAME + value: 'zid_test.{{ zone_one }}' + overwrite: True + identifier: "host1@www" + weight: 100 + region: '{{ omit }}' + register: weighted_record + - name: 'This should not be changed' + assert: + that: + - weighted_record is not failed + - weighted_record is not changed + always: - route53_info: query: record_sets @@ -521,6 +557,20 @@ loop: '{{ z1_records.ResourceRecordSets | selectattr("Type", "in", ["A", "AAAA", "CNAME", "CAA"]) | list }}' when: - '"AliasTarget" in item' + - name: 'Loop over A/AAAA/CNAME records and delete them' + route53: + state: absent + zone: '{{ zone_one }}' + record: '{{ item.Name }}' + type: '{{ item.Type }}' + value: '{{ item.ResourceRecords | map(attribute="Value") | join(",") }}' + identifier: '{{ item.SetIdentifier }}' + region: '{{ omit }}' + ignore_errors: True + loop: '{{ z1_records.ResourceRecordSets | selectattr("Type", "in", ["A", "AAAA", "CNAME", "CAA"]) | list }}' + when: + - '"ResourceRecords" in item' + - '"SetIdentifier" in item' - name: 'Loop over A/AAAA/CNAME records and delete them' route53: state: absent @@ -551,6 +601,21 @@ loop: '{{ z2_records.ResourceRecordSets | selectattr("Type", "in", ["A", "AAAA", "CNAME", "CAA"]) | list }}' when: - '"AliasTarget" in item' + - name: 'Loop over A/AAAA/CNAME records and delete them' + route53: + state: absent + zone: '{{ zone_two }}' + record: '{{ item.Name }}' + type: '{{ item.Type }}' + value: '{{ item.ResourceRecords | map(attribute="Value") | join(",") }}' + identifier: '{{ item.SetIdentifier }}' + region: '{{ omit }}' + private_zone: true + ignore_errors: True + loop: '{{ z2_records.ResourceRecordSets | selectattr("Type", "in", ["A", "AAAA", "CNAME", "CAA"]) | list }}' + when: + - '"ResourceRecords" in item' + - '"SetIdentifier" in item' - name: 'Loop over A/AAAA/CNAME records and delete them' route53: state: absent