Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x delete script fails to delete cloudformation due to route53 hostedzone #188

Closed
kaovilai opened this issue Nov 12, 2021 · 5 comments
Closed

Comments

@kaovilai
Copy link
Member

kaovilai commented Nov 12, 2021

hostedzone is unable to delete due to existing A records leftover from openshift-install

A records leftover are of this record name pattern

  • api.cluster-guid.guid.base_domain
    • elb with tag uuid: <guid>
  • *.apps.cluster-guid.guid.base_domain
    • elb with tag kubernetes.io/cluster/<cluster-name>: owned

where <cluster-name> is of pattern cluster-<shortened-guid>-<5-alphanumerics>
where <shortened-guid> is leftmost 13 characters from <guid>

@kaovilai
Copy link
Member Author

kaovilai commented Nov 12, 2021

@markuman
Copy link

As a workaround, you can iterate over all records via route53_info

    - name: grab zone id
      community.aws.route53_zone:
        zone: xn--mitlinuxwrdasnichtpassiert-ohc.de
      register: AWSINFO

    - name: grab Route53 record information
      community.aws.route53_info:
        query: record_sets
        hosted_zone_id: "{{ AWSINFO.zone_id }}"
      register: RECORDS

    - debug:
        var: RECORDS

and delete all records or just filter them ...
maybe this helps until the bug is fixed.

@markuman
Copy link

markuman commented Nov 12, 2021

Because of the next related bug you'll hit, here comes the next workaround :)
When you're iterating over RECORDS.ResourceRecordSets, you can keep all properties.

    - name: remove all records
      community.aws.route53:
        state: absent
        hosted_zone_id: "{{ AWSINFO.zone_id }}"
        record: "{{ item.Name }}"
        type: "{{ item.Type }}"
        value: "{{ item.ResourceRecords |  map(attribute='Value') | list }}"
        ttl: "{{ item.TTL }}"
        overwrite: yes
      with_items: "{{ RECORDS.ResourceRecordSets }}"

This works for all non alias records.
When you also have alias records, you must exclude then with when: when: item.AliasTarget is not defined and run a 2nd task where you just delete the alias records.

@kaovilai
Copy link
Member Author

kaovilai commented Nov 15, 2021

Got poc working with ansible-collections/community.aws#801. Thanks @markuman !

Next up item that is not removed

@kaovilai
Copy link
Member Author

No longer reproducible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants