Skip to content

Commit 36aff84

Browse files
authored
Add reference for db instance/cluster param/subnet/vpcsecurity group (#97)
Issue #, if available: aws-controllers-k8s/community#1378 Description of changes: Add reference for DBInstance/Cluster ParameterGroup/SubnetGroup/vpcSecurityGroup. Here is my testing process, it should apply to param group and vpc security group too. 1. Try create a rds instance `brucegu-test-ref-4` and specify ``` dbSubnetGroupRef: from: name: "brucegu-test-subnet-11"" ``` but no `brucegu-test-subnet-11` is available yet. 2. Verify db instance state has ``` Message: dbsubnetgroups.rds.services.k8s.aws "brucegu-test-subnet-11" not found Status: Unknown Type: ACK.ReferencesResolved ``` 3. Create db SubnetGroup `brucegu-test-subnet-11` from SubnetGroup CRD 4. Verify db instance `brucegu-test-ref-4` is created successfully and Resource synced successfully. ``` Conditions: Last Transition Time: 2022-07-07T22:09:25Z Status: True Type: ACK.ReferencesResolved Last Transition Time: 2022-07-07T22:09:26Z Message: Late initialization successful Reason: Late initialization successful Status: True Type: ACK.LateInitialized Last Transition Time: 2022-07-07T22:09:26Z Message: Resource synced successfully Reason: Status: True Type: ACK.ResourceSynced ``` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 2d2be9e commit 36aff84

19 files changed

+734
-13
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2022-07-06T21:17:58Z"
3-
build_hash: f9ab7cca7c2ea2ac77d0c4d2dfeb0b42ade56f38
2+
build_date: "2022-07-07T19:58:37Z"
3+
build_hash: 0aa529e87bd86c6ba52db8c3524ddecb2876bafe
44
go_version: go1.18.2
5-
version: v0.19.2-4-gf9ab7cc
6-
api_directory_checksum: d6c6f02d6f5547b3092054e9c7c35f5840f8bef9
5+
version: v0.19.2-5-g0aa529e
6+
api_directory_checksum: a60467e94dc7e76bf34ff50f21691507d576fefc
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.27
99
generator_config_info:
10-
file_checksum: 2d0c40614a7482376d47885f84cdb713d4307392
10+
file_checksum: bb74db41177efd5c2c2dee2b106ff4ad8e9adcdb
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/db_cluster.go

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

apis/v1alpha1/db_instance.go

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

apis/v1alpha1/generator.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ resources:
107107
resource: Key
108108
service_name: kms
109109
path: Status.ACKResourceMetadata.ARN
110+
DBClusterParameterGroupName:
111+
references:
112+
resource: DBClusterParameterGroup
113+
path: Spec.Name
114+
DBSubnetGroupName:
115+
references:
116+
resource: DBSubnetGroup
117+
path: Spec.Name
118+
VpcSecurityGroupIds:
119+
references:
120+
resource: SecurityGroup
121+
service_name: ec2
122+
path: Status.ID
110123
renames:
111124
operations:
112125
CreateDBCluster:
@@ -186,6 +199,19 @@ resources:
186199
resource: Key
187200
service_name: kms
188201
path: Status.ACKResourceMetadata.ARN
202+
DBParameterGroupName:
203+
references:
204+
resource: DBParameterGroup
205+
path: Spec.Name
206+
DBSubnetGroupName:
207+
references:
208+
resource: DBSubnetGroup
209+
path: Spec.Name
210+
VpcSecurityGroupIds:
211+
references:
212+
resource: SecurityGroup
213+
service_name: ec2
214+
path: Status.ID
189215
BackupTarget:
190216
late_initialize: {}
191217
NetworkType:

apis/v1alpha1/zz_generated.deepcopy.go

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

cmd/controller/main.go

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

config/crd/bases/rds.services.k8s.aws_dbclusters.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,41 @@ spec:
130130
of an existing DB cluster parameter group. \n Valid for: Aurora
131131
DB clusters and Multi-AZ DB clusters"
132132
type: string
133+
dbClusterParameterGroupRef:
134+
description: 'AWSResourceReferenceWrapper provides a wrapper around
135+
*AWSResourceReference type to provide more user friendly syntax
136+
for references using ''from'' field Ex: APIIDRef: from: name:
137+
my-api'
138+
properties:
139+
from:
140+
description: AWSResourceReference provides all the values necessary
141+
to reference another k8s resource for finding the identifier(Id/ARN/Name)
142+
properties:
143+
name:
144+
type: string
145+
type: object
146+
type: object
133147
dbSubnetGroupName:
134148
description: "A DB subnet group to associate with this DB cluster.
135149
\n This setting is required to create a Multi-AZ DB cluster. \n
136150
Constraints: Must match the name of an existing DBSubnetGroup. Must
137151
not be default. \n Example: mydbsubnetgroup \n Valid for: Aurora
138152
DB clusters and Multi-AZ DB clusters"
139153
type: string
154+
dbSubnetGroupRef:
155+
description: 'AWSResourceReferenceWrapper provides a wrapper around
156+
*AWSResourceReference type to provide more user friendly syntax
157+
for references using ''from'' field Ex: APIIDRef: from: name:
158+
my-api'
159+
properties:
160+
from:
161+
description: AWSResourceReference provides all the values necessary
162+
to reference another k8s resource for finding the identifier(Id/ARN/Name)
163+
properties:
164+
name:
165+
type: string
166+
type: object
167+
type: object
140168
deletionProtection:
141169
description: "A value that indicates whether the DB cluster has deletion
142170
protection enabled. The database can't be deleted when deletion
@@ -552,6 +580,22 @@ spec:
552580
items:
553581
type: string
554582
type: array
583+
vpcSecurityGroupRefs:
584+
items:
585+
description: 'AWSResourceReferenceWrapper provides a wrapper around
586+
*AWSResourceReference type to provide more user friendly syntax
587+
for references using ''from'' field Ex: APIIDRef: from: name:
588+
my-api'
589+
properties:
590+
from:
591+
description: AWSResourceReference provides all the values necessary
592+
to reference another k8s resource for finding the identifier(Id/ARN/Name)
593+
properties:
594+
name:
595+
type: string
596+
type: object
597+
type: object
598+
type: array
555599
required:
556600
- dbClusterIdentifier
557601
- engine

config/crd/bases/rds.services.k8s.aws_dbinstances.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ spec:
229229
character must be a letter \n * Can't end with a hyphen or contain
230230
two consecutive hyphens"
231231
type: string
232+
dbParameterGroupRef:
233+
description: 'AWSResourceReferenceWrapper provides a wrapper around
234+
*AWSResourceReference type to provide more user friendly syntax
235+
for references using ''from'' field Ex: APIIDRef: from: name:
236+
my-api'
237+
properties:
238+
from:
239+
description: AWSResourceReference provides all the values necessary
240+
to reference another k8s resource for finding the identifier(Id/ARN/Name)
241+
properties:
242+
name:
243+
type: string
244+
type: object
245+
type: object
232246
dbSnapshotIdentifier:
233247
description: "The identifier for the DB snapshot to restore from.
234248
\n Constraints: \n * Must match the identifier of an existing
@@ -241,6 +255,20 @@ spec:
241255
\n Constraints: Must match the name of an existing DBSubnetGroup.
242256
Must not be default. \n Example: mydbsubnetgroup"
243257
type: string
258+
dbSubnetGroupRef:
259+
description: 'AWSResourceReferenceWrapper provides a wrapper around
260+
*AWSResourceReference type to provide more user friendly syntax
261+
for references using ''from'' field Ex: APIIDRef: from: name:
262+
my-api'
263+
properties:
264+
from:
265+
description: AWSResourceReference provides all the values necessary
266+
to reference another k8s resource for finding the identifier(Id/ARN/Name)
267+
properties:
268+
name:
269+
type: string
270+
type: object
271+
type: object
244272
deletionProtection:
245273
description: "A value that indicates whether the DB instance has deletion
246274
protection enabled. The database can't be deleted when deletion
@@ -758,6 +786,22 @@ spec:
758786
items:
759787
type: string
760788
type: array
789+
vpcSecurityGroupRefs:
790+
items:
791+
description: 'AWSResourceReferenceWrapper provides a wrapper around
792+
*AWSResourceReference type to provide more user friendly syntax
793+
for references using ''from'' field Ex: APIIDRef: from: name:
794+
my-api'
795+
properties:
796+
from:
797+
description: AWSResourceReference provides all the values necessary
798+
to reference another k8s resource for finding the identifier(Id/ARN/Name)
799+
properties:
800+
name:
801+
type: string
802+
type: object
803+
type: object
804+
type: array
761805
required:
762806
- dbInstanceClass
763807
- dbInstanceIdentifier

config/rbac/cluster-role-controller.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ rules:
3232
- list
3333
- patch
3434
- watch
35+
- apiGroups:
36+
- ec2.services.k8s.aws
37+
resources:
38+
- securitygroups
39+
verbs:
40+
- get
41+
- list
42+
- apiGroups:
43+
- ec2.services.k8s.aws
44+
resources:
45+
- securitygroups/status
46+
verbs:
47+
- get
48+
- list
3549
- apiGroups:
3650
- kms.services.k8s.aws
3751
resources:

0 commit comments

Comments
 (0)