2017-10-05 67 views
0

我試圖更新一些CNAME記錄使用boto3上Route53託管A資源記錄,這裏是我的功能:(InvalidChangeBatch)調用ChangeResourceRecordSets操作時 - 使用boto3更新

def change_resource_record(domain, zone_id, hosted_zone_id, balancer_id): 
    print(domain, zone_id, hosted_zone_id, balancer_id) 
    client.change_resource_record_sets(
     HostedZoneId=zone_id, 
     ChangeBatch={ 
      "Comment": "Automatic DNS update", 
      "Changes": [ 
       { 
        "Action": "UPSERT", 
        "ResourceRecordSet": { 
         "Name": domain, 
         "Type": "A", 
         "AliasTarget": { 
          "HostedZoneId": hosted_zone_id, 
          "DNSName": balancer_id, 
          "EvaluateTargetHealth": False 
         } 
        } 
       }, 
      ] 
     } 
    ) 

我得到此錯誤:

Traceback (most recent call last): 
    File "load_balancer.py", line 138, in <module> 
    get_balancer(domain) 
    File "load_balancer.py", line 135, in get_balancer 
    change_resource_record(domain, zone_id, hosted_zone_id, balancer_id) 
    File "load_balancer.py", line 116, in change_resource_record 
    "EvaluateTargetHealth": False 
    File "C:\Python36\lib\site-packages\botocore\client.py", line 312, in _api_call 
    return self._make_api_call(operation_name, kwargs) 
    File "C:\Python36\lib\site-packages\botocore\client.py", line 601, in _make_api_call 
    raise error_class(parsed_response, operation_name) 
botocore.errorfactory.InvalidChangeBatch: An error occurred (InvalidChangeBatch) when calling the ChangeResourceRecordSets operation: RRSet of type A with DNS name suffix.domain.tld. is not permitted because a conflicting RRSet of type CNAME with the same DNS name already exists in zone domain.tld. 

什麼是更新記錄的正確方法,我應該刪除條目然後重新創建它嗎?

任何意見是非常感謝。

回答

0

我在domain有缺少一個右期,所以改變這個解決我的問題:

  "ResourceRecordSet": { 
       "Name": domain + '.', 
       "Type": "A", 
       "AliasTarget": { 
        "HostedZoneId": hosted_zone_id, 
        "DNSName": balancer_id, 
        "EvaluateTargetHealth": False 
       } 
      } 
相關問題