Reputation: 1687
I'm trying to update the type of an existing record using boto3.change_resource_record_sets
in my current case, I'm trying to change a record from type A to type CNAME - with matching values.
I'm getting the following error:
botocore.errorfactory.InvalidChangeBatch:
An error occurred (InvalidChangeBatch) when calling the ChangeResourceRecordSets
operation: RRSet of type A with DNS name test.test.v3.prod.example.com.
is not permitted because a conflicting RRSet of type CNAME with the same
DNS name already exists in zone test.v3.prod.example.com.
This operation exactly can be accomplished via AWS UI (Only an update of a record in the same zone I'm trying to update from my code).
This is my code:
def update_record(zone_id):
batch = {
'Changes': [
{
'Action': 'UPSERT',
'ResourceRecordSet' : {
'Name' : 'test.test.v3.prod.example.com.',
'Type' : 'CNAME',
'TTL' : 15,
'ResourceRecords' : [{'Value': 'www.example.com'}]
}
}
]
}
# THIS LINE THROWS THE EXCEPTION
response = client.change_resource_record_sets(HostedZoneId=zone_id, ChangeBatch=batch)
return response
Any ideas?
Upvotes: 2
Views: 2321
Reputation: 497
You cannot change the record type with UPSERT. The name and the type are used as a key for which ttl and resource records to change. Your Changes should be:
batch = {
'Changes': [
{
'Action': 'DELETE',
'ResourceRecordSet' : {
'Name' : 'test.test.v3.prod.example.com.',
'Type' : 'A', # or AAAA
'TTL' : 15,
'ResourceRecords' : [{'Value': '1.2.3.4'}] # or whatever it is
}
},
{
'Action': 'UPSERT', # INSERT, really!
'ResourceRecordSet' : {
'Name' : 'test.test.v3.prod.example.com.',
'Type' : 'CNAME',
'TTL' : 15,
'ResourceRecords' : [{'Value': 'www.example.com'}]
}
]
}
Upvotes: 4