Skip to content

Instantly share code, notes, and snippets.

@michaelact
Last active June 14, 2024 14:59
Show Gist options
  • Save michaelact/1c2272c255b0b636227d4569715204ab to your computer and use it in GitHub Desktop.
Save michaelact/1c2272c255b0b636227d4569715204ab to your computer and use it in GitHub Desktop.
Export all of your zonefile from Amazon Route 53
#!/bin/bash
# Reference: https://stackoverflow.com/questions/20337749/exporting-dns-zonefile-from-amazon-route-53
HOSTED_ZONE_IDS=$(aws route53 list-hosted-zones --query "HostedZones[*].Id" --output text)
for zoneId in $HOSTED_ZONE_IDS; do \
echo $zoneId >> records.txt
aws route53 list-resource-record-sets --hosted-zone-id $zoneId --output json | jq -jr '.ResourceRecordSets[] | "\(.Name) \t\(.TTL) \t\(.Type) \t\(.ResourceRecords[]?.Value)\n"' >> records.txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment