Amazon web services Boto3-更改\u资源\u记录\u设置更改记录类型失败
我正在尝试使用boto3.change\u resource\u record\u set更新现有记录的类型在我当前的情况下,我正在尝试使用匹配的值将记录从类型a更改为类型CNAME 我得到以下错误:Amazon web services Boto3-更改\u资源\u记录\u设置更改记录类型失败,amazon-web-services,python-3.6,amazon-route53,Amazon Web Services,Python 3.6,Amazon Route53,我正在尝试使用boto3.change\u resource\u record\u set更新现有记录的类型在我当前的情况下,我正在尝试使用匹配的值将记录从类型a更改为类型CNAME 我得到以下错误: botocore.errorfactory.InvalidChangeBatch: An error occurred (InvalidChangeBatch) when calling the ChangeResourceRecordSets operation: RRSet of type A
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.
此操作完全可以通过AWS UI完成,只需更新我试图从代码更新的同一区域中的记录
这是我的代码:
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
有什么想法吗?您不能使用UPSERT更改记录类型。名称和类型用作要更改其ttl和资源记录的键。您的更改应该是:
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'}]
}
]
}
不能使用UPSERT更改记录类型。名称和类型用作要更改其ttl和资源记录的键。您的更改应该是:
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'}]
}
]
}