Skip to content

Add roleARN parameter to ManagerFor in resource manager factory #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.22.4

require (
github.com/aws-controllers-k8s/pkg v0.0.15
github.com/aws-controllers-k8s/runtime v0.37.1
github.com/aws-controllers-k8s/runtime v0.37.2-0.20240829063928-a606fd18ca1f
github.com/aws/aws-sdk-go v1.49.0
github.com/dlclark/regexp2 v1.10.0 // indirect
// pin to v0.1.1 due to release problem with v0.1.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ github.com/aws-controllers-k8s/pkg v0.0.15 h1:C1pnD/aDqJsU9oYf5upHkpSc+Hv4JQVtkd
github.com/aws-controllers-k8s/pkg v0.0.15/go.mod h1:VvdjLWmR6IJ3KU8KByKiq/lJE8M+ur2piXysXKTGUS0=
github.com/aws-controllers-k8s/runtime v0.37.1 h1:OKSG3WnswkazWgUtSZh3RApU6OK3l01LklP1DjWgEFY=
github.com/aws-controllers-k8s/runtime v0.37.1/go.mod h1:gI2pWb20UGLP2SnHf1a1VzTd7iVVy+/I9VAzT0Y+Dew=
github.com/aws-controllers-k8s/runtime v0.37.2-0.20240829063928-a606fd18ca1f h1:N5WNMehmiBNdthmGYlua3P0P+i6hctfGVEtPe4QHme8=
github.com/aws-controllers-k8s/runtime v0.37.2-0.20240829063928-a606fd18ca1f/go.mod h1:gI2pWb20UGLP2SnHf1a1VzTd7iVVy+/I9VAzT0Y+Dew=
github.com/aws/aws-sdk-go v1.49.0 h1:g9BkW1fo9GqKfwg2+zCD+TW/D36Ux+vtfJ8guF4AYmY=
github.com/aws/aws-sdk-go v1.49.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down
1 change: 1 addition & 0 deletions pkg/generate/ack/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (rmf *fakeRMF) ManagerFor(
*session.Session,
ackv1alpha1.AWSAccountID,
ackv1alpha1.AWSRegion,
ackv1alpha1.AWSResourceName,
) (acktypes.AWSResourceManager, error) {
return nil, nil
}
Expand Down
6 changes: 5 additions & 1 deletion templates/pkg/resource/manager_factory.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ func (f *resourceManagerFactory) ManagerFor(
sess *session.Session,
id ackv1alpha1.AWSAccountID,
region ackv1alpha1.AWSRegion,
roleARN ackv1alpha1.AWSResourceName,
) (acktypes.AWSResourceManager, error) {
rmId := fmt.Sprintf("%s/%s", id, region)
// We use the account ID, region, and role ARN to uniquely identify a
// resource manager. This helps us to avoid creating multiple resource
// managers for the same account/region/roleARN combination.
rmId := fmt.Sprintf("%s/%s/%s", id, region, roleARN)
f.RLock()
rm, found := f.rmCache[rmId]
f.RUnlock()
Expand Down