SHARE
TWEET

Untitled

a guest Jun 18th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. set -ex
  3.  
  4. [ $# -ne 3 ] && echo "Usage $0 <your zone id> <your domain> <your ip>" && exit 1
  5.  
  6. MY_ZONE_ID=$1
  7. MY_DOMAIN=$2
  8. MY_IP=$3
  9.  
  10. TMPFILE=$(mktemp /tmp/${MY_DOMAIN}_upsert_${MY_IP}.XXXXXX)
  11. cat <<-EOF > ${TMPFILE}
  12. {
  13.   "Comment": "Update IP via awscli",
  14.   "Changes": [
  15.     {
  16.       "Action": "UPSERT",
  17.       "ResourceRecordSet": {
  18.         "Name": "${MY_DOMAIN}",
  19.         "Type": "A",
  20.         "TTL": 30,
  21.         "ResourceRecords": [
  22.           {
  23.             "Value": "${MY_IP}"
  24.           }
  25.         ]
  26.       }
  27.     }
  28.   ]
  29. }
  30. EOF
  31.  
  32. aws route53 change-resource-record-sets --hosted-zone-id /hostedzone/${MY_ZONE_ID} --change-batch file://${TMPFILE}
  33. aws route53 list-resource-record-sets --hosted-zone-id /hostedzone/${MY_ZONE_ID} | jq ".[][] | select(.Name==\"${MY_DOMAIN}\")"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top