Skip to content

Instantly share code, notes, and snippets.

@ChandanChainani
Forked from afeld/domains.sh
Created September 13, 2022 18:35
Show Gist options
  • Save ChandanChainani/81b306ee8261026b34805a8377ee568c to your computer and use it in GitHub Desktop.
Save ChandanChainani/81b306ee8261026b34805a8377ee568c to your computer and use it in GitHub Desktop.
get all domains (record sets) from all zones in an account in AWS Route53
#!/bin/bash
set -eo pipefail
aws route53 list-hosted-zones --query 'HostedZones[].Id' | \
jq -r '.[]' | sed 's/\/hostedzone\///' \
| \
xargs -I zone_id \
aws route53 list-resource-record-sets \
--hosted-zone-id zone_id \
--query "ResourceRecordSets[?Type == 'A' || Type == 'AAAA' || Type == 'CNAME'].Name" | \
jq -r '.[]' \
| \
sed -E 's/^www\.|\.$//' | egrep -v '_domainkey|\w{30,}' | sort -u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment