Create an AWS Route53 zone in a delegation set and change the NS record to match your vanity nameservers
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 | |
if [ -z "$1" ]; then | |
echo "Please specify domain name" | |
exit 1 | |
fi | |
initials="WH" | |
delegationsetid="YOUR-DELEGATED-SET-ID" | |
reference="$initials$(date +%Y%m%d%H%M%S)" | |
# create zone in AWS and store json output | |
zone=$(aws route53 create-hosted-zone --delegation-set-id $delegationsetid --caller-reference $reference --name $1) | |
# extract the new zone ID from the json output | |
zoneid=$(echo "$zone" | jq .HostedZone.Id | awk -F '/' '{print $3}') | |
# trim the trailing quote | |
zoneid="${zoneid%\"}" | |
change="{\"ChangeBatch\":{\"Changes\":[{\"Action\":\"UPSERT\",\"ResourceRecordSet\":{\"Name\":\"$1\",\"Type\":\"NS\",\"TTL\":172800,\"ResourceRecords\":[{\"Value\":\"ns1.example.net\"},{\"Value\":\"ns2.example.net\"},{\"Value\":\"ns3.example.net\"},{\"Value\":\"ns4.example.net\"}]}}]}}" | |
reference="$initials$(date +%Y%m%d%H%M%S)" | |
changeresult=$(aws route53 change-resource-record-sets --hosted-zone-id $zoneid --cli-input-json $change) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment