gruntwork-io / cloud-nuke

A tool for cleaning up your cloud accounts by nuking (deleting) all resources within it
https://gruntwork.io/
MIT License
2.81k stars 358 forks source link

route53-hosted-zone - can't delete a hosted zone containing record sets (DNS entries) #704

Closed sbocinec closed 5 months ago

sbocinec commented 6 months ago

The recently added Route53 hosted zone nuke implementation https://github.com/gruntwork-io/cloud-nuke/pull/646 allows to delete a Route53 Hosted zone, though, it can only nuke an empty zone - zone that only contains 2 "required" NS & SOA entries created by default and no others. If there is any custom DNS record set created in the zone, the nuke of the zone fails with:

ERROR   [Failed] /hostedzone/Z1234567890: HostedZoneNotEmpty: The specified hosted zone contains non-required resource record sets and so cannot be deleted.                                                               
            status code: 400, request id: e0ed1ea1-2d48-4e4e-839c-3b5108b1f99f

The reason is, that all the record sets other than NS and SOA must be deleted first, prior attempting to delete the zone.

ATM cloud-nuke does not allow to delete hosted zone's record-sets.