Last active
October 26, 2015 10:37
-
-
Save miyukki/b402e1bb9de98856003b to your computer and use it in GitHub Desktop.
家のIPをcronでRoute53に登録する便利スクリプト
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/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