Skip to content

Commit 67c13d1

Browse files
chore: Add DelegationSet to Status for HostedZone (#64)
Issue #, if available: aws-controllers-k8s/community#2364 Description of changes: Add the DelegationSet to the Status of HostedZone resources so the nameservers can be retrieved to then be referenced in a RecordSet for a different HostedZone. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. I'm not sure if there's a more proper way to get the sdkCreate and sdkFind calls to be generated with the relevant logic without the hook but I couldn't find a way to get that to happen. As such I've gone down the hook path.
1 parent 31f639c commit 67c13d1

11 files changed

+107
-4
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2025-02-20T18:21:43Z"
2+
build_date: "2025-03-03T23:36:46Z"
33
build_hash: a326346bd3a6973254d247c9ab2dc76790c36241
44
go_version: go1.24.0
55
version: v0.43.2
6-
api_directory_checksum: 0e842f9492e354f790fd6f70698b57776324fc31
6+
api_directory_checksum: b920521646bacef1fba9d0b97a423d11565c7a60
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.32.6
99
generator_config_info:
10-
file_checksum: af1e20f94f0b1e81627c90fa1b82bf77ff994e48
10+
file_checksum: 262cace7fe285ca8833a0f656963c0f5872b0404
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ resources:
163163
- InvalidInput
164164
- InvalidVPCId
165165
fields:
166+
DelegationSet:
167+
from:
168+
operation: CreateHostedZone
169+
path: DelegationSet
170+
is_read_only: true
166171
Tags:
167172
from:
168173
operation: ChangeTagsForResource

apis/v1alpha1/hosted_zone.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/route53.services.k8s.aws_hostedzones.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,19 @@ spec:
205205
privateZone:
206206
type: boolean
207207
type: object
208+
delegationSet:
209+
description: A complex type that describes the name servers for this
210+
hosted zone.
211+
properties:
212+
callerReference:
213+
type: string
214+
id:
215+
type: string
216+
nameServers:
217+
items:
218+
type: string
219+
type: array
220+
type: object
208221
id:
209222
description: |-
210223
The ID that Amazon Route 53 assigned to the hosted zone when you created

generator.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ resources:
163163
- InvalidInput
164164
- InvalidVPCId
165165
fields:
166+
DelegationSet:
167+
from:
168+
operation: CreateHostedZone
169+
path: DelegationSet
170+
is_read_only: true
166171
Tags:
167172
from:
168173
operation: ChangeTagsForResource

helm/crds/route53.services.k8s.aws_hostedzones.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,19 @@ spec:
205205
privateZone:
206206
type: boolean
207207
type: object
208+
delegationSet:
209+
description: A complex type that describes the name servers for this
210+
hosted zone.
211+
properties:
212+
callerReference:
213+
type: string
214+
id:
215+
type: string
216+
nameServers:
217+
items:
218+
type: string
219+
type: array
220+
type: object
208221
id:
209222
description: |-
210223
The ID that Amazon Route 53 assigned to the hosted zone when you created

pkg/resource/hosted_zone/sdk.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/hooks/hosted_zone/sdk_create_post_set_output.go.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
latest.ko = &svcapitypes.HostedZone{}
44
latest.ko.Status.ID = ko.Status.ID
55

6+
if resp.DelegationSet != nil {
7+
f := &svcapitypes.DelegationSet{}
8+
if resp.DelegationSet.NameServers != nil {
9+
f.NameServers = aws.StringSlice(resp.DelegationSet.NameServers)
10+
}
11+
ko.Status.DelegationSet = f
12+
} else {
13+
ko.Status.DelegationSet = nil
14+
}
15+
616
// This is create operation. So, no tags are present in HostedZone.
717
// So, 'latest' is empty except we have copied 'ID' into the status to
818
// make syncTags() happy.
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
if err := rm.setResourceAdditionalFields(ctx, ko); err != nil {
22
return nil, err
3-
}
3+
}
4+
5+
if resp.DelegationSet != nil {
6+
f := &svcapitypes.DelegationSet{}
7+
if resp.DelegationSet.NameServers != nil {
8+
f.NameServers = aws.StringSlice(resp.DelegationSet.NameServers)
9+
}
10+
ko.Status.DelegationSet = f
11+
} else {
12+
ko.Status.DelegationSet = nil
13+
}

test/e2e/tests/test_hosted_zone.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,24 @@ def test_create_delete_private(self, route53_client, private_hosted_zone):
108108
# Check hosted_zone exists in AWS
109109
route53_validator = Route53Validator(route53_client)
110110
route53_validator.assert_hosted_zone(zone_id)
111+
@pytest.mark.resource_data({'tag_key': 'key', 'tag_value': 'value'})
112+
def test_delegation_set(self, route53_client, public_hosted_zone):
113+
ref, cr = public_hosted_zone
114+
115+
time.sleep(CREATE_WAIT_AFTER_SECONDS)
116+
117+
resource = k8s.get_resource(ref)
118+
resource_id = cr["status"]["id"]
119+
120+
assert resource_id
121+
122+
123+
# Check hosted_zone exists in AWS
124+
route53_validator = Route53Validator(route53_client)
125+
route53_validator.assert_hosted_zone(resource_id)
126+
127+
assert resource["status"]["delegationSet"] is not None
128+
assert len(resource["status"]["delegationSet"]["nameServers"]) > 0
111129

112130
@pytest.mark.resource_data({'tag_key': 'initialtagkey', 'tag_value': 'initialtagvalue'})
113131
def test_crud_tags(self, route53_client, public_hosted_zone):

0 commit comments

Comments
 (0)