#!/bin/bash -eu set -o pipefail HOSTED_ZONE_ID="/hostedzone/Z00026583L98XLGPBWMM8" rm -f change-resource-record-sets.json IFS='' read -r -d '' resource_update << EOS { "Comment": "Update record to reflect new IP address for a system ", "Changes": [ { "Action": "UPSERT", "ResourceRecordSet": { "Name": "gitlab.orion-technologies.io", "Type": "A", "TTL": 300, "ResourceRecords": [ { "Value": "$(wget -qO- https://ipecho.net/plain ; echo)" } ] } } ] } EOS echo \ "Issuing command: aws route53 change-resource-record-sets --hosted-zone-id ${HOSTED_ZONE_ID} --change-batch json-data-update(see script)" result="$(aws --no-cli-auto-prompt route53 change-resource-record-sets --hosted-zone-id "${HOSTED_ZONE_ID}" --change-batch "${resource_update}")" echo \ "Current Record Status: $(jq '.ChangeInfo.Status' <(echo "${result}"))" current_time="$(date +%Y-%m-%dT%H:%M:%S)" cat << EOF >> DDNS_Updates.log DDNS Update made @ ${current_time} EOF