Skip to content

Instantly share code, notes, and snippets.

@leonaugusto16
Created October 16, 2019 19:50
Show Gist options
  • Save leonaugusto16/deab47d9fa51de4416d8c656f10d86ab to your computer and use it in GitHub Desktop.
Save leonaugusto16/deab47d9fa51de4416d8c656f10d86ab to your computer and use it in GitHub Desktop.
#!/bin/sh
ip_private=$(curl http://169.254.169.254/latest/meta-data/local-ipv4)
dns_name="<YOUR_DNS>"
template='{"Comment": "UPSERT record machines ","Changes": [{"Action": "UPSERT","ResourceRecordSet": {"Name":"%s","Type": "A","TTL": 300,"ResourceRecords": [{"Value": "%s"}]}}]}'
json_string=$(printf "$template" "$dns_name" "$ip_private")
echo $json_string > change-batch.json
aws route53 change-resource-record-sets --hosted-zone-id <ID_ZONE> --change-batch file://change-batch.json
rm -rf change-batch.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment