Created
November 7, 2016 23:53
-
-
Save dstokes/8eaa4a3d885a16fe7cbf16e5dc7198a7 to your computer and use it in GitHub Desktop.
Test Dead Route53 DNS Records
This file contains 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 | |
DOMAIN=$1 | |
PORT=$2 | |
TYPES=(A CNAME) | |
# resolve zone id | |
ZONE=$(aws route53 list-hosted-zones --query 'HostedZones[?Name==`'$DOMAIN'.`].Id' --output text) | |
if [[ -z "$ZONE" ]]; then | |
echo "Unrecognized domain: $1" >&2 | |
exit 1 | |
fi | |
for type in "${TYPES[@]}"; do | |
RECORDS=$(aws route53 list-resource-record-sets --hosted-zone-id "${ZONE##*/}" --query 'ResourceRecordSets[?Type==`'$type'`].[Name]' --output text) | |
IFS=$'\n' | |
for r in $RECORDS; do | |
HOST=$(echo "$r" | sed 's/\.$//') | |
(nc -vz -w1 "$HOST" $PORT >/dev/null 2>&1 || echo "$HOST") & | |
done | |
done | |
wait $(jobs -p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment