Skip to content

Commit 1d88d6e

Browse files
authored
Add support for Security Group Adoption (#165)
Issue #, if available: aws-controllers-k8s/community#1946 Description of changes: The existing logic doesn't allow for adoption of existing SecurityGroups because spec.Name is a required property for creation but the aws SDK returns GroupName. The deepCopy in sdkFind then is not enough because of the different names. By copying SecurityGroup GroupName into spec.Name as part of the sdk_read_many_post_set_output we solve this issue. This fix allows adoption of existing security groups. Tests have been successful in at least two test scenarios: adopting an existing SG and then modifying its properties, trying to adopt an invalid SG. I've also ran a few additional tests with the modified controller to be sure that existing functionality didn't break: * Create a new SG * Modify this SG * Delete this SG By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 3ac4413 commit 1d88d6e

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

apis/v1alpha1/ack-generate-metadata.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ack_generate_info:
2-
build_date: "2024-01-03T22:47:06Z"
3-
build_hash: 00e081fb541587f33970ad80c99f2ac02e9c2525
2+
build_date: "2024-01-15T16:33:37Z"
3+
build_hash: 3753ca3f6610172e9e652d6e5e62e0a05f2e639c
44
go_version: go1.21.5
5-
version: v0.28.0-8-g00e081f
5+
version: v0.28.0-11-g3753ca3
66
api_directory_checksum: 8b27f9e65dbad1f5f825c84d1dbe8fd333baf2a5
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.93

pkg/resource/security_group/sdk.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.

templates/hooks/security_group/sdk_read_many_post_set_output.go.tpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
if found {
2+
3+
// Needed because SecurityGroups Name are held in GroupName property of the AWS resource
4+
ko.Spec.Name = resp.SecurityGroups[0].GroupName
5+
26
rm.addRulesToSpec(ko, resp.SecurityGroups[0])
37
48
// A ReadOne call for SecurityGroup Rules (NOT SecurityGroups)
@@ -8,4 +12,4 @@
812
} else {
913
ko.Status.Rules = rules
1014
}
11-
}
15+
}

0 commit comments

Comments
 (0)