Bash_Scripts/AWS/DDNS.bash

39 lines
1.1 KiB
Bash
Raw Normal View History

2021-08-02 07:06:49 -05:00
#!/bin/bash
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 route53 change-resource-record-sets --hosted-zone-id "${HOSTED_ZONE_ID}" --change-batch "${resource_update}")"
echo \
"Current Record Status:
$(jq '.ChangeInfo.Status' <(echo "${result}"))"
2021-08-02 15:27:02 -05:00
current_time="$(date +%Y-%m-%dT%H:%M:%S)"
cat << EOF >> DDNS_Updates.log
DDNS Update made @ ${current_time}
EOF