2012-07-11 50 views
9

我正在使用以下命令刪除route53記錄。我沒有收到錯誤消息。Boto - 如何從route53刪除記錄集 - 嘗試刪除資源記錄集但未找到

conn = Route53Connection(aws_access_key_id, aws_secret_access_key) 
changes = ResourceRecordSets(conn, zone_id) 
change = changes.add_change("DELETE",sub_domain, "A", 60,weight=weight,identifier=identifier) 
change.add_value(ip_old) 
changes.commit() 

所有必需的字段存在和它們match..weight,標識符 TTL = 60等。\

例如

test.com. A 111.111.111.111 60 1 id1 
test.com. A 111.111.111.222 60 1 id2 

我想刪除111.111.111.222和記錄集。

那麼,刪除記錄集的正確方法是什麼?

對於一個記錄集,我將擁有多個通過唯一標識符區分 的值。當一個IP地址變爲活動狀態時,我想要 從路由53中刪除。我正在使用可憐的負載均衡。

Here is the meta of the record want to delete. 
{'alias_dns_name': None, 
    'alias_hosted_zone_id': None, 
    'identifier': u'15754-1', 
    'name': u'hui.com.', 
    'resource_records': [u'103.4.xxx.xxx'], 
    'ttl': u'60', 
    'type': u'A', 
    'weight': u'1'} 



Traceback (most recent call last): 
    File "/home/ubuntu/workspace/rtbopsConfig/classes/redis_ha.py", line 353, in <module> 
    deleteRedisSubDomains(aws_access_key_id, aws_secret_access_key,platform=platform,sub_domain=sub_domain,redis_domain=redis_domain,zone_id=zone_id,ip_address=ip_address,weight=1,identifier=identifier) 
    File "/home/ubuntu/workspace/rtbopsConfig/classes/redis_ha.py", line 341, in deleteRedisSubDomains 
    changes.commit() 
    File "/usr/local/lib/python2.7/dist-packages/boto-2.3.0-py2.7.egg/boto/route53/record.py", line 131, in commit 
    return self.connection.change_rrsets(self.hosted_zone_id, self.to_xml()) 
    File "/usr/local/lib/python2.7/dist-packages/boto-2.3.0-py2.7.egg/boto/route53/connection.py", line 291, in change_rrsets 
    body) 
boto.route53.exception.DNSServerError: DNSServerError: 400 Bad Request 
<?xml version="1.0"?> 
<ErrorResponse xmlns="https://route53.amazonaws.com/doc/2011-05-05/"><Error><Type>Sender</Type><Code>InvalidChangeBatch</Code><Message>Tried to delete resource record set hui.com., type A, SetIdentifier 15754-1 but it was not found</Message></Error><RequestId>9972af89-cb69-11e1-803b-7bde5b9c457d</RequestId></ErrorResponse> 

感謝

回答

1

你確定你需要所有這些參數對add_change?

Look at add_change here.

默認參數被賦予給該函數,所以你可能被過指定通過提供重量和TTL。

嘗試讓重量和TTL離開(您可能需要保留標識符)。 This blog提供了一個刪除記錄的簡單示例:

此外,我看不到您傳遞的參數的值,但確保其完整性並嘗試包括'。'。在你的子域的末尾

1

我試過類似的例子,並且必須指定包括weight和ttl在內的所有字段才能成功刪除。 (通過保持默認狀態,它不起作用)。無法用加權DNS記錄產生原始問題並明確通過ttl。