2016-10-22 4 views
4

Route 53のDNSレコードを削除するにはどうすればよいですか?私はdocumentationに従っていますが、それでも動作させることはできません。私はここに何かを逃しているかどうか分からない。AWS Python SDK | Route 53 - リソースレコードを削除する

DELETE : Deletes a existing resource record set that has the specified values for Name , Type , SetIdentifier (for latency, weighted, geolocation, and failover resource record sets), and TTL (except alias resource record sets, for which the TTL is determined by the AWS resource that you're routing DNS queries to).

しかし、私はいつもこのエラーを取得しています:

Traceback (most recent call last):                                  
    File "./test.py", line 37, in <module>                                 
    main()                                        
    File "./test.py", line 34, in main                                  
    print(del_record())                                     
    File "./test.py", line 23, in del_record                                
    'TTL': 300                                       
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/botocore/client.py", line 251, in _api_call          
    return self._make_api_call(operation_name, kwargs)                             
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/botocore/client.py", line 537, in _make_api_call         
    raise ClientError(parsed_response, operation_name)                             
botocore.exceptions.ClientError: An error occurred (InvalidInput) when calling the ChangeResourceRecordSets operation: Invalid request 

は、ここに私のコードです:

#!/usr/bin/env python3 


import boto3 

r53 = boto3.client('route53') 
zone_id = 'ABCDEFGHIJKLMNO' 
record = 'me.domain.com' 
r_type = 'CNAME' 
r_val = 'google.com' 


def del_record(): 
    response = r53.change_resource_record_sets(
     HostedZoneId=zone_id, 
     ChangeBatch={ 
      'Changes': [ 
       { 
        'Action': 'DELETE', 
        'ResourceRecordSet': { 
         'Name': record, 
         'Type': r_type, 
         'TTL': 300 
        } 
       } 
      ] 
     } 
    ) 

    return response 


def main(): 
    print(del_record()) 

if __name__ == '__main__': 
    main() 

答えて

5

あなたは、ネストされた 'ResourceRecords' を必要とする文書に基づいて

レコードの現在の 'target'値を持つResourceRecordSet内の配列。

HostedZoneId=zone_id, 
    ChangeBatch={ 
     'Changes': [ 
      { 
       'Action': 'DELETE', 
       'ResourceRecordSet': { 
        'Name': record, 
        'Type': r_type, 
        'TTL': 300, 
        'ResourceRecords': [ 
         { 
          'Value': target 
         } 
        ] 
       } 
      } 
     ] 
    } 
+5

私は彼らがこの機能を変更したことを非常に残念です。あなたは "名前"に基づいてレコードを削除することができました。 Value、TTL、Typeが必要なので、削除を行う前に多くのルックアップを行う必要があります。 –

関連する問題