Files
homelab-route53-dns/update-dns.sh
Max Regan 9afb7e685f Fix issues with creating orphan processes
By using bash (which plays nicely by reparenting orphan processes)
2019-12-16 04:11:58 +00:00

33 lines
591 B
Bash

#!/bin/bash
set -eux
ip=$(wget https://checkip.amazonaws.com/ -O - -q)
zone_id=$(aws route53 list-hosted-zones | jq -S '.HostedZones | .[] | select( .Name == "maxregan.me." ) | .Id' -r)
batch=$(cat <<EOM
{
"Changes": [
{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "home.maxregan.me",
"Type": "A",
"TTL": $((30 * 60)),
"ResourceRecords": [
{
"Value": "${ip}"
}
]
}
}
]
}
EOM
)
aws route53 change-resource-record-sets --hosted-zone-id "${zone_id}" --change-batch "$batch"
wait