Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script to update Route53 with the current public IP of an instance
hosted_zone_id="<your Route53 hosted zone id>"
domain_name="<your domain name>"
# Abort script on any errors
set -e
# Get new IP address
# Build temporary file
cat > ./dnsupdate.json <<EOF
"Changes": [
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "$domain_name",
"Type": "A",
"TTL": 300,
"ResourceRecords": [
"Value": "$ip_address"
# Call Route53 to update DNS
aws route53 change-resource-record-sets --hosted-zone-id $hosted_zone_id --change-batch file://./dnsupdate.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment