I'm trying to get an dynamic DNS updater script working using AWS Route 53, python3 and boto3. It functions as follows:
Step 4 is not working. The code for it is below. my_ip contains a string that looks like this: 1.2.3.4. I have tried replacing it with a string directly ("Value": "1.2.3.4") but that didn't fix the error. hosted_zone_id is correct as it was already used to pull the IP address. record_name is "microbug.uk.".
response = client.change_resource_record_sets(
HostedZoneId=hosted_zone_id,
ChangeBatch={
"Comment": "Automatic DNS update",
"Changes": [
{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": record_name,
"Type": "A",
"Region": "eu-west-1",
"TTL": 180,
"ResourceRecords": [
{
"Value": my_ip
},
],
}
},
]
}
)
This is the error it throws:
Traceback (most recent call last):
File "update-dns.py", line 42, in <module>
"Value": my_ip
File "/usr/lib/python3.5/site-packages/botocore/client.py", line 278, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/lib/python3.5/site-packages/botocore/client.py", line 572, in _make_api_call
raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidInput) when calling the ChangeResourceRecordSets operation: Invalid request
Any suggestions? Thanks in advance.
edit:
$ cat ~/.aws/config
[default]
region = eu-west-1
output = json
I solved the problem. The Region option must only be set for latency-based record sets; commenting it out solved the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With