Sometimes you just want to get all the records for all the domains you have hosted at Route 53. You might want to look through them for some setting or anomaly. But clicking around the AWS console is tedious.
The AWS API can rescue you from the tedium. With two simple commands, you can see all your DNS records.
First, get all the hosted zones. You typically have one zone per domain name. So culturefoundry.com is a zone. (This assumes you have jq installed, which is a must if you are doing any command line processing of json. Trust me, you’ll thank me.)
aws route53 list-hosted-zones|jq '. | . | .Id' | sed 's!/hostedzone/!!' | sed 's/"//g'> zones
Then, for each of these zone ids, we want to pull all the record sets and store them off to a file for further examination later.
for z in `cat zones`; do echo $z; aws route53 list-resource-record-sets --hosted-zone-id $z >> records; done
When I have to do something repeatedly with AWS, I always ask myself: “is this a readonly operation?” If so, I often reach for the unix command line tools, jq and the aws CLI, as above.