Created
August 26, 2023 05:49
-
-
Save ThabetAmer/d17686429a5b3faf72d9114b4691f894 to your computer and use it in GitHub Desktop.
Retrieves DNS zone records for a domain on AWS Route53
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 | |
# @description : retrieves DNS zone records for a domain hosted on AWS Route53 | |
# @usage : bash get-route53-domain-records.sh example.com | |
# @requirements: proper awscli v2 setup | |
# @input : domain name, you own! | |
# @output : text formatted records | |
DOMAIN=$1 | |
test -z "$DOMAIN" && { echo "ERROR: no domain value is set" && exit -1; } | |
DOMAIN_ID=$(aws route53 list-hosted-zones-by-name --dns-name $DOMAIN --query "HostedZones[].Id" --output text) | |
test -z "$DOMAIN_ID" && { echo "ERROR: no domain ID retrieved, make sure the domain set is hosted on your account" && exit -2; } | |
DOMAIN_RECORDS=$(aws route53 list-resource-record-sets --hosted-zone-id $DOMAIN_ID --output text) | |
echo "$DOMAIN_RECORDS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment