Created
January 29, 2018 09:58
-
-
Save tibu/8f9c061fa0818ea565e42933ccec42c0 to your computer and use it in GitHub Desktop.
Download zone file in bind format from AWS Route53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# download zone from AWS Route53 | |
zonename=$1 | |
hostedzoneid=$(aws route53 list-hosted-zones | jq -r ".HostedZones[] | select(.Name == \"$zonename.\") | .Id" | cut -d'/' -f3) | |
aws route53 list-resource-record-sets --hosted-zone-id $hostedzoneid --output json | jq -jr '.ResourceRecordSets[] | "\(.Name) \t\(.TTL) \t\(.Type) \t\(.ResourceRecords[].Value)\n"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for the script. It works fine for hosted zones which have only A record types. However, it can be improved to handle the AWS Route 53's proprietary
AliasTarget
records. For example, the above script would fail withjq: error (at <stdin>:n): Cannot iterate over null (null)
exception if we pass this json file intojq
: