Browse Source

Merge pull request #430 from joschi36/aws-support-delegationsetid

AWS Route53: Add Parameter for DelegationSetId
pull/465/head
Ross McFarland 6 years ago
committed by GitHub
parent
commit
a796b946eb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 106 additions and 3 deletions
  1. +10
    -3
      octodns/provider/route53.py
  2. +96
    -0
      tests/test_octodns_provider_route53.py

+ 10
- 3
octodns/provider/route53.py View File

@ -618,8 +618,9 @@ class Route53Provider(BaseProvider):
def __init__(self, id, access_key_id=None, secret_access_key=None,
max_changes=1000, client_max_attempts=None,
session_token=None, *args, **kwargs):
session_token=None, delegation_set_id=None, *args, **kwargs):
self.max_changes = max_changes
self.delegation_set_id = delegation_set_id
_msg = 'access_key_id={}, secret_access_key=***, ' \
'session_token=***'.format(access_key_id)
use_fallback_auth = access_key_id is None and \
@ -674,10 +675,16 @@ class Route53Provider(BaseProvider):
return id
if create:
ref = uuid4().hex
del_set = self.delegation_set_id
self.log.debug('_get_zone_id: no matching zone, creating, '
'ref=%s', ref)
resp = self._conn.create_hosted_zone(Name=name,
CallerReference=ref)
if del_set:
resp = self._conn.create_hosted_zone(Name=name,
CallerReference=ref,
DelegationSetId=del_set)
else:
resp = self._conn.create_hosted_zone(Name=name,
CallerReference=ref)
self.r53_zones[name] = id = resp['HostedZone']['Id']
return id
return None


+ 96
- 0
tests/test_octodns_provider_route53.py View File

@ -370,6 +370,16 @@ class TestRoute53Provider(TestCase):
return (provider, stubber)
def _get_stubbed_delegation_set_provider(self):
provider = Route53Provider('test', 'abc', '123',
delegation_set_id="ABCDEFG123456")
# Use the stubber
stubber = Stubber(provider._conn)
stubber.activate()
return (provider, stubber)
def _get_stubbed_fallback_auth_provider(self):
provider = Route53Provider('test')
@ -913,6 +923,92 @@ class TestRoute53Provider(TestCase):
self.assertEquals(9, provider.apply(plan))
stubber.assert_no_pending_responses()
def test_sync_create_with_delegation_set(self):
provider, stubber = self._get_stubbed_delegation_set_provider()
got = Zone('unit.tests.', [])
list_hosted_zones_resp = {
'HostedZones': [],
'Marker': 'm',
'IsTruncated': False,
'MaxItems': '100',
}
stubber.add_response('list_hosted_zones', list_hosted_zones_resp,
{})
plan = provider.plan(self.expected)
self.assertEquals(9, len(plan.changes))
self.assertFalse(plan.exists)
for change in plan.changes:
self.assertIsInstance(change, Create)
stubber.assert_no_pending_responses()
create_hosted_zone_resp = {
'HostedZone': {
'Name': 'unit.tests.',
'Id': 'z42',
'CallerReference': 'abc',
},
'ChangeInfo': {
'Id': 'a12',
'Status': 'PENDING',
'SubmittedAt': '2017-01-29T01:02:03Z',
'Comment': 'hrm',
},
'DelegationSet': {
'Id': 'b23',
'CallerReference': 'blip',
'NameServers': [
'n12.unit.tests.',
],
},
'Location': 'us-east-1',
}
stubber.add_response('create_hosted_zone',
create_hosted_zone_resp, {
'Name': got.name,
'CallerReference': ANY,
'DelegationSetId': 'ABCDEFG123456'
})
list_resource_record_sets_resp = {
'ResourceRecordSets': [{
'Name': 'a.unit.tests.',
'Type': 'A',
'GeoLocation': {
'ContinentCode': 'NA',
},
'ResourceRecords': [{
'Value': '2.2.3.4',
}],
'TTL': 61,
}],
'IsTruncated': False,
'MaxItems': '100',
}
stubber.add_response('list_resource_record_sets',
list_resource_record_sets_resp,
{'HostedZoneId': 'z42'})
stubber.add_response('list_health_checks',
{
'HealthChecks': self.health_checks,
'IsTruncated': False,
'MaxItems': '100',
'Marker': '',
})
stubber.add_response('change_resource_record_sets',
{'ChangeInfo': {
'Id': 'id',
'Status': 'PENDING',
'SubmittedAt': '2017-01-29T01:02:03Z',
}}, {'HostedZoneId': 'z42', 'ChangeBatch': ANY})
self.assertEquals(9, provider.apply(plan))
stubber.assert_no_pending_responses()
def test_health_checks_pagination(self):
provider, stubber = self._get_stubbed_provider()


Loading…
Cancel
Save