我有以下bash脚本,用于更新DNS记录:
#!/bin/sh
# Update the DNS for Production DB
RECORD=$1
if [ -z "${RECORD}" ]; then
echo "Please provide a valid record (URL endpoint) to the database"
exit 1
fi
aws route53 change-resource-record-sets --hosted-zone-id ZPXXX --cli-input-json "{\"HostedZoneId\":\"Z1R8UBAEXAMPLE\",\"ChangeBatch\":{\"Changes\":[{\"Action\":\"UPSERT\",\"ResourceRecordSet\":{\"Name\":\"catalogue-write-database-prod..domain.tld.\",\"Type\":\"CNAME\",\"TTL\":300,\"ResourceRecords\":[{\"Value\":\"${RECORD}\"}]}}]}}"
ID=$(aws route53 change-resource-record-sets --hosted-zone-id ZPXXX --cli-input-json "{\"HostedZoneId\":\"Z1R8UBAEXAMPLE\",\"ChangeBatch\":{\"Changes\":[{\"Action\":\"UPSERT\",\"ResourceRecordSet\":{\"Name\":\"catalogue-read-database-prod.domain.tld.\",\"Type\":\"CNAME\",\"TTL\":300,\"ResourceRecords\":[{\"Value\":\"${RECORD}\"}]}}]}}" | grep "/change/" | cut -c 15- | sed -e 's/"//g')
echo "Change ID: ${ID}"
aws route53 get-change --id ${ID} | grep INSYNC
while [ $? -ne 0 ]
do
echo "WAITING FOR DNS TO UPDATE... PLEASE WAIT"
sleep 5s
aws route53 get-change --id ${ID} | grep INSYNC
done
但是我得到了
An error occurred (NoSuchChange) when calling the GetChange operation: Could not find resource with ID: CG1AG9APE0Q8J,
我的aws版本是:
+ aws --version
aws-cli/1.16.291 Python/3.4.2 Linux/3.16.0-25-generic botocore/1.13.27
在此版本上,脚本可以正确运行
+ aws --version
aws-cli/1.9.15 Python/2.7.8 Linux/3.16.0-25-generic botocore/1.3.15
任何建议都非常感谢