Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test Dead Route53 DNS Records
#!/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
You can’t perform that action at this time.