Skip to content

Commit c0efeb7

Browse files
committed
feat: Store resource partition in Status
1 parent 119cbe3 commit c0efeb7

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

templates/pkg/resource/identifiers.go.tpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,12 @@ func (ri *resourceIdentifiers) Region() *ackv1alpha1.AWSRegion {
4040
}
4141
return nil
4242
}
43+
44+
// Partition returns the AWS partition in which the reosurce exists, or
45+
// nil if this information is not known.
46+
func (ri *resourceIdentifiers) Partition() *ackv1alpha1.AWSPartition {
47+
if ri.meta != nil {
48+
return ri.meta.Partition
49+
}
50+
return nil
51+
}

templates/pkg/resource/manager.go.tpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ type resourceManager struct {
6262
awsAccountID ackv1alpha1.AWSAccountID
6363
// The AWS Region that this resource manager targets
6464
awsRegion ackv1alpha1.AWSRegion
65+
// The AWS Partition that this resource manager targets
66+
awsPartition ackv1alpha1.AWSPartition
6567
// sdk is a pointer to the AWS service API client exposed by the
6668
// aws-sdk-go-v2/services/{alias} package.
6769
sdkapi *svcsdk.Client
@@ -180,7 +182,8 @@ func (rm *resourceManager) Delete(
180182
// name for the resource
181183
func (rm *resourceManager) ARNFromName(name string) string {
182184
return fmt.Sprintf(
183-
"arn:aws:{{ .ControllerName }}:%s:%s:%s",
185+
"arn:%s:{{ .ControllerName }}:%s:%s:%s",
186+
rm.awsPartition,
184187
rm.awsRegion,
185188
rm.awsAccountID,
186189
name,
@@ -435,6 +438,7 @@ func newResourceManager(
435438
rr: rr,
436439
awsAccountID: id,
437440
awsRegion: region,
441+
awsPartition: ackv1alpha1.AWSPartition(cfg.Partition),
438442
sdkapi: svcsdk.NewFromConfig(clientcfg{{- if $hookCode := Hook .CRD "new_resource_manager_client_options" }}, {{ $hookCode }}{{ end }}),
439443
}, nil
440444
}

templates/pkg/resource/sdk.go.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ func (rm *resourceManager) setStatusDefaults (
202202
if ko.Status.ACKResourceMetadata.Region == nil {
203203
ko.Status.ACKResourceMetadata.Region = &rm.awsRegion
204204
}
205+
if ko.Status.ACKResourceMetadata.Partition == nil {
206+
ko.Status.ACKResourceMetadata.Partition = &rm.awsPartition
207+
}
205208
if ko.Status.ACKResourceMetadata.OwnerAccountID == nil {
206209
ko.Status.ACKResourceMetadata.OwnerAccountID = &rm.awsAccountID
207210
}

0 commit comments

Comments
 (0)