Last active
August 17, 2016 08:54
-
-
Save pahud/c3b90d5151c0471efa0fb018b4ff813b to your computer and use it in GitHub Desktop.
update_route53_on_ec2_launch
This file contains hidden or 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 | |
# save this file as /root/update_route53.sh and run "bash /root/update_route53.sh" in the UserData | |
# Author: [email protected] 2016/08/10 | |
publicIp=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4) | |
hostId='XXXXXXXXX' | |
cat > /tmp/update.json <<EOF | |
{ | |
"Changes": [ | |
{ | |
"Action": "UPSERT", | |
"ResourceRecordSet": { | |
"Name": "myhost.example.com", | |
"Type": "A", | |
"TTL": 60, | |
"ResourceRecords": [ | |
{ | |
"Value": "${publicIp}" | |
} | |
] | |
} | |
} | |
] | |
} | |
EOF | |
aws route53 change-resource-record-sets --hosted-zone-id $hostId --change-batch file:////tmp/update.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
make sure the EC2 run as appropriate role with the following policy