Skip to content

Instantly share code, notes, and snippets.

@miyukki
Last active October 26, 2015 10:37
Show Gist options
  • Save miyukki/b402e1bb9de98856003b to your computer and use it in GitHub Desktop.
Save miyukki/b402e1bb9de98856003b to your computer and use it in GitHub Desktop.
家のIPをcronでRoute53に登録する便利スクリプト
#!/bin/sh
ZONE_ID="XXXX"
HOSTNAME="example.com"
IPADDR=`curl http://ipecho.net/plain`
TEMPFILE='/tmp/route53-record.json'
cat << EOS > $TEMPFILE
{
"Changes": [
{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "$HOSTNAME",
"Type": "A",
"TTL": 120,
"ResourceRecords": [
{
"Value": "$IPADDR"
}
]
}
}
]
}
EOS
aws route53 change-resource-record-sets --hosted-zone-id $ZONE_ID --change-batch file://$TEMPFILE
rm -rf $TEMPFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment