Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -ex
- [ $# -ne 3 ] && echo "Usage $0 <your zone id> <your domain> <your ip>" && exit 1
- MY_ZONE_ID=$1
- MY_DOMAIN=$2
- MY_IP=$3
- TMPFILE=$(mktemp /tmp/${MY_DOMAIN}_upsert_${MY_IP}.XXXXXX)
- cat <<-EOF > ${TMPFILE}
- {
- "Comment": "Update IP via awscli",
- "Changes": [
- {
- "Action": "UPSERT",
- "ResourceRecordSet": {
- "Name": "${MY_DOMAIN}",
- "Type": "A",
- "TTL": 30,
- "ResourceRecords": [
- {
- "Value": "${MY_IP}"
- }
- ]
- }
- }
- ]
- }
- EOF
- aws route53 change-resource-record-sets --hosted-zone-id /hostedzone/${MY_ZONE_ID} --change-batch file://${TMPFILE}
- aws route53 list-resource-record-sets --hosted-zone-id /hostedzone/${MY_ZONE_ID} | jq ".[][] | select(.Name==\"${MY_DOMAIN}\")"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement