I could not find a good tutorial for deleting route53 records in DNS.
This requires that you have jq installed first
Find my hosted zones id
$ aws --region us-west-1 --profile client-terraform \ route53 list-hosted-zones-by-name --dns-name example.net \ |jq .HostedZones[].Id \ "/hostedzone/MYZONEID"
Get the actual record
$ aws --region us-west-1 --profile client-terraform route53 \ list-resource-record-sets --hosted-zone-id=MYZONEID \ jq '.ResourceRecordSets[] | select (.Name == "staging.example.net.")' { "Name": "staging.example.net.", "Type": "CNAME", "TTL": 300, "ResourceRecords": [ { "Value": "a.us-west-1.elb.amazonaws.com" } ] }
Create a JSON file using the information from above
$ cat /tmp/delete.json { "Comment": "delete this record", "Changes": [ { "Action": "DELETE", "ResourceRecordSet": { "Name": "app.example.net.", "Type": "CNAME", "TTL": 300, "ResourceRecords": [ { "Value": "a4.us-west-1.elb.amazonaws.com" } ] } } ] }
Actually delete the record
aws --region us-west-1 --profile client-terraform route53 \ change-resource-record-sets \ --hosted-zone-id=MYZONEID --change-batch file:///tmp/delete.json