Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boto - How to delete a record set from route53 -Tried to delete resource record set but it was not found

I am using the following to delete route53 records. I get no error messages.

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()

all required fields are present and they match..weight, identifier, ttl=60 etc.\

e.g.

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

I want to delete 111.111.111.222 and the record set.

So, what is the proper way to delete a record set?

For a record set, I will have multiple values that are distinguished by a unique identifier. When an ip address becomes in active I want to remove from route53. I am using a a poor mans load balancing.

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>

Thanks

like image 789
Tampa Avatar asked Jul 11 '12 01:07

Tampa


2 Answers

Are you sure you need all of those parameters for add_change?

Look at add_change here.

Default parameters are given to the function, so you may be over-specifying by providing weight and TTL.

Try leaving weight and TTL out (you may need to keep identifier). This blog provides a simple example of deleting records:

Also, I can't see the values of your parameters that you're passing, but ensure their integrity and try including a '.' at the end of your subdomain

like image 97
grokpot Avatar answered Oct 13 '22 19:10

grokpot


I tried similar example and had to specify all fields including weight and ttl for a successful deletion. (By keeping it default, it did not work). Could not produce the original problem with weighted DNS record and explicitly passed ttl.

like image 37
sukrit007 Avatar answered Oct 13 '22 17:10

sukrit007