Skip to content

Instantly share code, notes, and snippets.

@sorah
Created May 2, 2015 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorah/efcdde4a912d3be90024 to your computer and use it in GitHub Desktop.
Save sorah/efcdde4a912d3be90024 to your computer and use it in GitHub Desktop.
#!/bin/bash
new_ip="$(curl -s -4 http://api.ipify.org)"
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