@@ -30,6 +30,24 @@ func (f *resourceManagerFactory) ResourceDescriptor() acktypes.AWSResourceDescri
30
30
return &resourceDescriptor{}
31
31
}
32
32
33
+ // GetCachedManager returns a manager object that can manage resources for a
34
+ // supplied AWS account if it was already created and cached, or nil if not
35
+ func (f *resourceManagerFactory) GetCachedManager(
36
+ id ackv1alpha1.AWSAccountID,
37
+ region ackv1alpha1.AWSRegion,
38
+ roleARN ackv1alpha1.AWSResourceName,
39
+ ) acktypes.AWSResourceManager {
40
+ // We use the account ID, region, and role ARN to uniquely identify a
41
+ // resource manager. This helps us to avoid creating multiple resource
42
+ // managers for the same account/region/roleARN combination.
43
+ rmId := fmt.Sprintf(" %s/%s/%s" , id, region, roleARN)
44
+ f.RLock()
45
+ rm, _ := f.rmCache[rmId]
46
+ f.RUnlock()
47
+
48
+ return rm
49
+ }
50
+
33
51
// ManagerFor returns a resource manager object that can manage resources for a
34
52
// supplied AWS account
35
53
func (f *resourceManagerFactory) ManagerFor(
@@ -40,24 +58,17 @@ func (f *resourceManagerFactory) ManagerFor(
40
58
rr acktypes.Reconciler,
41
59
id ackv1alpha1.AWSAccountID,
42
60
region ackv1alpha1.AWSRegion,
61
+ partition ackv1alpha1.AWSPartition,
43
62
roleARN ackv1alpha1.AWSResourceName,
44
63
) (acktypes.AWSResourceManager, error) {
45
- // We use the account ID, region, and role ARN to uniquely identify a
46
- // resource manager. This helps us to avoid creating multiple resource
47
- // managers for the same account/region/roleARN combination.
48
- rmId := fmt.Sprintf(" %s/%s/%s" , id, region, roleARN)
49
- f.RLock()
50
- rm, found := f.rmCache[rmId]
51
- f.RUnlock()
52
-
53
- if found {
54
- return rm, nil
55
- }
56
-
57
64
f.Lock()
58
65
defer f.Unlock()
59
66
60
- rm, err := newResourceManager(cfg, clientcfg, log, metrics, rr, id, region)
67
+ // We use the account ID, region, partition, and role ARN to uniquely identify a
68
+ // resource manager. This helps us to avoid creating multiple resource
69
+ // managers for the same account/region/roleARN combination.
70
+ rmId := fmt.Sprintf(" %s/%s/%s" , id, region, roleARN)
71
+ rm, err := newResourceManager(cfg, clientcfg, log, metrics, rr, id, region, partition)
61
72
if err != nil {
62
73
return nil, err
63
74
}
0 commit comments