Skip to content

Commit 4a8f9cd

Browse files
authored
fix: use env accountID for SNS topic ARNs instead of app (#2956)
Fixes #2949 By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
1 parent 477ef47 commit 4a8f9cd

5 files changed

Lines changed: 16 additions & 12 deletions

File tree

internal/pkg/cli/job_deploy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ func (o *deployJobOpts) runtimeConfig(addonsURL string) (*stack.RuntimeConfig, e
323323
AddonsTemplateURL: addonsURL,
324324
AdditionalTags: tags.Merge(o.targetApp.Tags, o.resourceTags),
325325
ServiceDiscoveryEndpoint: endpoint,
326-
AccountID: o.targetApp.AccountID,
326+
AccountID: o.targetEnvironment.AccountID,
327327
Region: o.targetEnvironment.Region,
328328
}, nil
329329
}
@@ -348,7 +348,7 @@ func (o *deployJobOpts) runtimeConfig(addonsURL string) (*stack.RuntimeConfig, e
348348
AddonsTemplateURL: addonsURL,
349349
AdditionalTags: tags.Merge(o.targetApp.Tags, o.resourceTags),
350350
ServiceDiscoveryEndpoint: endpoint,
351-
AccountID: o.targetApp.AccountID,
351+
AccountID: o.targetEnvironment.AccountID,
352352
Region: o.targetEnvironment.Region,
353353
}, nil
354354
}

internal/pkg/cli/svc_deploy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ func (o *deploySvcOpts) runtimeConfig(addonsURL string) (*stack.RuntimeConfig, e
486486
AddonsTemplateURL: addonsURL,
487487
AdditionalTags: tags.Merge(o.targetApp.Tags, o.resourceTags),
488488
ServiceDiscoveryEndpoint: endpoint,
489-
AccountID: o.targetApp.AccountID,
489+
AccountID: o.targetEnvironment.AccountID,
490490
Region: o.targetEnvironment.Region,
491491
}, nil
492492
}
@@ -512,7 +512,7 @@ func (o *deploySvcOpts) runtimeConfig(addonsURL string) (*stack.RuntimeConfig, e
512512
Digest: o.imageDigest,
513513
},
514514
ServiceDiscoveryEndpoint: endpoint,
515-
AccountID: o.targetApp.AccountID,
515+
AccountID: o.targetEnvironment.AccountID,
516516
Region: o.targetEnvironment.Region,
517517
}, nil
518518
}

internal/pkg/cli/svc_package.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func (o *packageSvcOpts) getSvcTemplates(env *config.Environment) (*svcCfnTempla
390390
rc := stack.RuntimeConfig{
391391
AdditionalTags: app.Tags,
392392
ServiceDiscoveryEndpoint: endpoint,
393-
AccountID: app.AccountID,
393+
AccountID: env.AccountID,
394394
Region: env.Region,
395395
}
396396

internal/pkg/cli/svc_package_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,12 @@ count: 1`
300300
opts.newInterpolator = func(app, env string) interpolator {
301301
return mockItpl
302302
}
303-
opts.stackSerializer = func(_ interface{}, _ *config.Environment, _ *config.Application, _ stack.RuntimeConfig) (stackSerializer, error) {
303+
opts.stackSerializer = func(_ interface{}, _ *config.Environment, _ *config.Application, rc stack.RuntimeConfig) (stackSerializer, error) {
304304
mockStackSerializer := mocks.NewMockstackSerializer(ctrl)
305305
mockStackSerializer.EXPECT().Template().Return("mystack", nil)
306306
mockStackSerializer.EXPECT().SerializedParameters().Return("myparams", nil)
307+
require.Equal(t, rc.AccountID, "1111", "ensure the environment's account is used while rendering stack")
308+
require.Equal(t, rc.Region, "us-west-2")
307309
return mockStackSerializer, nil
308310
}
309311
opts.newEndpointGetter = func(app, env string) (endpointGetter, error) {

internal/pkg/deploy/cloudformation/stack/workload.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ const (
6161
// RuntimeConfig represents configuration that's defined outside of the manifest file
6262
// that is needed to create a CloudFormation stack.
6363
type RuntimeConfig struct {
64-
Image *ECRImage // Optional. Image location in an ECR repository.
65-
AddonsTemplateURL string // Optional. S3 object URL for the addons template.
66-
AdditionalTags map[string]string // AdditionalTags are labels applied to resources in the workload stack.
67-
ServiceDiscoveryEndpoint string // Endpoint for the service discovery namespace in the environment.
68-
AccountID string // Account ID for constructing ARNs
69-
Region string // Region for constructing ARNs
64+
Image *ECRImage // Optional. Image location in an ECR repository.
65+
AddonsTemplateURL string // Optional. S3 object URL for the addons template.
66+
AdditionalTags map[string]string // AdditionalTags are labels applied to resources in the workload stack.
67+
68+
// The target environment metadata.
69+
ServiceDiscoveryEndpoint string // Endpoint for the service discovery namespace in the environment.
70+
AccountID string
71+
Region string
7072
}
7173

7274
// ECRImage represents configuration about the pushed ECR image that is needed to

0 commit comments

Comments
 (0)