Created
December 11, 2023 04:07
-
-
Save kawaz/6728dc6aaecd590f99ae9a920c8c71eb to your computer and use it in GitHub Desktop.
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 | |
set -e -o pipefail | |
# HostedZone[].Id を保存 | |
aws route53 list-hosted-zones | jq .HostedZones[].Id -r | tee HostedZoneIds.txt | |
# 全HostedZoneのRecordSetを取得 | |
while read id; do | |
aws route53 list-resource-record-sets --hosted-zone-id "$id" | |
done <HostedZoneIds.txt | tee rs.json.tmp | |
[[ $? == 0 ]] || exit | |
mv rs.json.tmp rs.json | |
# RecordSetリストをシンプルな形に加工 | |
cat rs.json | | |
jq '.ResourceRecordSets[]|{Name,Type,v:"\(.ResourceRecords//[]|map(.Value)|join(","))\(.AliasTarget.DNSName//"")"}|.+{v:(.v|split(","))}' -c | | |
perl -pe's/\."/"/g' | | |
tee rs-digest.json | | |
grep -vE -e '"(SOA|NS|TXT|MX)"' -e '(acm-validations.aws)' | | |
jq .Name -r | | |
perl -pe's/\.$//' | | |
tee fqdns.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment