Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Add function to delete DNS records
Browse files Browse the repository at this point in the history
Adds a function to delete DNS records. To be consumed by other packages
that use the create functions here.
  • Loading branch information
mattmb committed Jul 3, 2015
1 parent d562895 commit db33ccc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bootstrap_cfn/r53.py
Expand Up @@ -45,3 +45,12 @@ def get_record(self, zone, zone_id, record, record_type):
rr.resource_records[0] = rr.resource_records[0][1:-1]
return rr.resource_records[0]
return None

def delete_dns_record(self, zone, record, record_type):
'''
Returns True if delete successful or raises an exception if not
'''
changes = boto.route53.record.ResourceRecordSets(self.conn_r53, zone)
changes.add_change("DELETE", record, record_type)
changes.commit()
return True
9 changes: 9 additions & 0 deletions tests/test_r53.py
Expand Up @@ -17,6 +17,15 @@ def setUp(self):
self.env.application = 'unittest-app'
self.env.config = os.path.join(self.work_dir, 'test_config.yaml')

def test_delete_dns_record(self):
r53_mock = mock.Mock()
r53_connect_result = mock.Mock(name='cf_connect')
r53_mock.return_value = r53_connect_result
boto.route53.connect_to_region = r53_mock
r = r53.R53(self.env.aws_profile)
x = r.delete_dns_record('blah/blah', 'x.y', 'A')
self.assertTrue(x)

def test_update_dns_record(self):
r53_mock = mock.Mock()
r53_connect_result = mock.Mock(name='cf_connect')
Expand Down

0 comments on commit db33ccc

Please sign in to comment.