When I run this boto3 to create or upsert an A record, I get the error:
File "./metakube.py", line 523, in post_create self.route53_update_alias_record(self.fugu_editor_external_dns, fugu_elb_identifier)
File "./metakube.py", line 508, in route53_update_alias_record 'EvaluateTargetHealth': False
File "/home/pairaccount/.virtualenvs/fugui-devops/local/lib/python2.7/site-packages/botocore/client.py", line 236, in _api_call return self._make_api_call(operation_name, kwargs)
File "/home/pairaccount/.virtualenvs/fugui-devops/local/lib/python2.7/site-packages/botocore/client.py", line 500, in _make_api_call raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidInput) when calling the ChangeResourceRecordSets operation: Invalid request
Based on the boto3 documentation this looks like the correct input. We've tried a few different variations too, but we get this error when we try to Create or Upsert an A record with this method below. We have a similar method that calls change_resource_record_sets
to delete an A record and it works fine.
Any ideas on what needs to be corrected?
def route53_update_alias_record(self, external_dns_name, load_balancer_identifier):
route53_client = boto3.client('route53')
hosted_zone_id = self.get_hosted_zone_id(route53_client)
response = route53_client.change_resource_record_sets(
HostedZoneId=hosted_zone_id,
ChangeBatch={
'Comment': 'upsert alias record',
'Changes': [
{
'Action': 'UPSERT',
'ResourceRecordSet': {
'Name': external_dns_name,
'Type': 'A',
'Region': 'us-east-1',
'AliasTarget': {
'DNSName': load_balancer_identifier,
'HostedZoneId': 'Z3DZXE0Q79N41H',
'EvaluateTargetHealth': False
}
}
}
]
}
)
self.logger.info("Delete route53 alias {} response: {}".format(external_dns_name, response))
On the Hosted zones page, choose the name of the hosted zone that you want to create records in. Choose Create record. Choose and define the applicable routing policy and values.
UPSERT : If a resource set exists Route 53 updates it with the values in the request.
Amazon Route 53 is designed to propagate updates you make to your DNS records to its world-wide network of authoritative DNS servers within 60 seconds under normal conditions.
Does Route 53 support MX Records? It supports CNAME records, but not MX records.
you need TTL
like :
response = client.change_resource_record_sets(
HostedZoneId=hostedzoneid,
ChangeBatch={
'Comment': 'add record',
'Changes': [
{
'Action': 'UPSERT',
'ResourceRecordSet': {
'Name': name,
'Type': 'A',
'TTL': ttl,
'ResourceRecords': [
{
'Value': value
}
]
}
}
]
}
)
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