Skip to content

Instantly share code, notes, and snippets.

@jroehl
Created February 16, 2018 14:41
Show Gist options
  • Save jroehl/69b40a69da87c730553c50cd22d770d6 to your computer and use it in GitHub Desktop.
Save jroehl/69b40a69da87c730553c50cd22d770d6 to your computer and use it in GitHub Desktop.
Update the nameserver of a domain with the nameservers of a specified hostedzone
#!/bin/bash
# Update the nameserver of a domain with the nameservers of a specified hostedzone
# aws-update-nameservers.sh HostedZoneId
HOSTED_ZONE_ID=$1
RESULT=(`aws route53 get-hosted-zone --query '[DelegationSet.NameServers,HostedZone.Name]' --output text --region us-east-1 --id $HOSTED_ZONE_ID `)
NAMESERVERS=("${RESULT[@]:1}")
SANITIZED_NAMESERVERS=${NAMESERVERS[@]/#/Name=}
DOMAIN_NAME="${RESULT[0]%?}"
echo "Updating nameservers for \"$DOMAIN_NAME\" with nameservers \"$NAMESERVERS\""
OP_ID=`aws route53domains update-domain-nameservers --region us-east-1 --domain-name $DOMAIN_NAME --nameservers $SANITIZED_NAMESERVERS`
echo $OP_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment