Skip to content

Instantly share code, notes, and snippets.

@sorah
Created November 18, 2014 18:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorah/efa66b2ac6ce2cec8828 to your computer and use it in GitHub Desktop.
Save sorah/efa66b2ac6ce2cec8828 to your computer and use it in GitHub Desktop.
r53-ddns (Route 53 DDNS)
#!/bin/bash
new_ip=`curl -s -4 http://ifconfig.me/ip`
zone_id=$1
target_name=$2
batch_json='
{
"Changes": [{
"Action": "UPSERT",
"ResourceRecordSet": {
"ResourceRecords": [
{
"Value": "'$new_ip'"
}
],
"Type": "A",
"Name": "'$target_name'",
"TTL": 300
}
}]
}'
echo "$zone_id/$target_name = $new_ip"
echo "--"
echo "${batch_json}"
echo "vv"
aws route53 change-resource-record-sets \
--hosted-zone-id $zone_id \
--change-batch "${batch_json}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment