我需要使用boto3函数删除SOA和NS以外的托管区域的所有记录。我使用了以下代码,但会引发错误。
错误消息
{
"errorMessage": "An error occurred (InvalidChangeBatch) when calling the ChangeResourceRecordSets operation: [Tried to delete resource record set [name='muneesh.gq.',type='TXT'] but it was not found]","errorType": "InvalidChangeBatch","stackTrace": [
" File \"/var/task/lambda_function.py\",line 19,in lambda_handler\n 'Value': 'jeeva1.gq'\n"," File \"/var/runtime/botocore/client.py\",line 357,in _api_call\n return self._make_api_call(operation_name,kwargs)\n",line 661,in _make_api_call\n raise error_class(parsed_response,operation_name)\n"
]
}
我使用了BOTO3代码
import logging
import boto3
import json
from botocore.exceptions import ClientError
def lambda_handler(event,context):
client = boto3.client('route53')
response = client.change_resource_record_sets(
HostedZoneId='ZJYD3I8IAL0UA',ChangeBatch={
'Changes': [
{
'action': 'DELETE','ResourceRecordSet': {
'Name': 'jeeva.gq.','Type': 'TXT','TTL': 300,'ResourceRecords': [
{
'Value': 'muneesh.gq'
}
]
}
}
]
}
)
预期输出: 如果我的托管区域名称是muneesh.gq。如果我的托管区域具有多个记录,例如A,CNAME.TXT,NS,SOA,则boto3函数应删除NS和SOA记录以外的所有记录。
谢谢。