Skip to content

Commit

Permalink
fix: use env accountID for SNS topic ARNs instead of app (#2956)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
efekarakus authored Oct 27, 2021
1 parent 477ef47 commit 4a8f9cd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions internal/pkg/cli/job_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func (o *deployJobOpts) runtimeConfig(addonsURL string) (*stack.RuntimeConfig, e
AddonsTemplateURL: addonsURL,
AdditionalTags: tags.Merge(o.targetApp.Tags, o.resourceTags),
ServiceDiscoveryEndpoint: endpoint,
AccountID: o.targetApp.AccountID,
AccountID: o.targetEnvironment.AccountID,
Region: o.targetEnvironment.Region,
}, nil
}
Expand All @@ -348,7 +348,7 @@ func (o *deployJobOpts) runtimeConfig(addonsURL string) (*stack.RuntimeConfig, e
AddonsTemplateURL: addonsURL,
AdditionalTags: tags.Merge(o.targetApp.Tags, o.resourceTags),
ServiceDiscoveryEndpoint: endpoint,
AccountID: o.targetApp.AccountID,
AccountID: o.targetEnvironment.AccountID,
Region: o.targetEnvironment.Region,
}, nil
}
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/cli/svc_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func (o *deploySvcOpts) runtimeConfig(addonsURL string) (*stack.RuntimeConfig, e
AddonsTemplateURL: addonsURL,
AdditionalTags: tags.Merge(o.targetApp.Tags, o.resourceTags),
ServiceDiscoveryEndpoint: endpoint,
AccountID: o.targetApp.AccountID,
AccountID: o.targetEnvironment.AccountID,
Region: o.targetEnvironment.Region,
}, nil
}
Expand All @@ -512,7 +512,7 @@ func (o *deploySvcOpts) runtimeConfig(addonsURL string) (*stack.RuntimeConfig, e
Digest: o.imageDigest,
},
ServiceDiscoveryEndpoint: endpoint,
AccountID: o.targetApp.AccountID,
AccountID: o.targetEnvironment.AccountID,
Region: o.targetEnvironment.Region,
}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cli/svc_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func (o *packageSvcOpts) getSvcTemplates(env *config.Environment) (*svcCfnTempla
rc := stack.RuntimeConfig{
AdditionalTags: app.Tags,
ServiceDiscoveryEndpoint: endpoint,
AccountID: app.AccountID,
AccountID: env.AccountID,
Region: env.Region,
}

Expand Down
4 changes: 3 additions & 1 deletion internal/pkg/cli/svc_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,12 @@ count: 1`
opts.newInterpolator = func(app, env string) interpolator {
return mockItpl
}
opts.stackSerializer = func(_ interface{}, _ *config.Environment, _ *config.Application, _ stack.RuntimeConfig) (stackSerializer, error) {
opts.stackSerializer = func(_ interface{}, _ *config.Environment, _ *config.Application, rc stack.RuntimeConfig) (stackSerializer, error) {
mockStackSerializer := mocks.NewMockstackSerializer(ctrl)
mockStackSerializer.EXPECT().Template().Return("mystack", nil)
mockStackSerializer.EXPECT().SerializedParameters().Return("myparams", nil)
require.Equal(t, rc.AccountID, "1111", "ensure the environment's account is used while rendering stack")
require.Equal(t, rc.Region, "us-west-2")
return mockStackSerializer, nil
}
opts.newEndpointGetter = func(app, env string) (endpointGetter, error) {
Expand Down
14 changes: 8 additions & 6 deletions internal/pkg/deploy/cloudformation/stack/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ const (
// RuntimeConfig represents configuration that's defined outside of the manifest file
// that is needed to create a CloudFormation stack.
type RuntimeConfig struct {
Image *ECRImage // Optional. Image location in an ECR repository.
AddonsTemplateURL string // Optional. S3 object URL for the addons template.
AdditionalTags map[string]string // AdditionalTags are labels applied to resources in the workload stack.
ServiceDiscoveryEndpoint string // Endpoint for the service discovery namespace in the environment.
AccountID string // Account ID for constructing ARNs
Region string // Region for constructing ARNs
Image *ECRImage // Optional. Image location in an ECR repository.
AddonsTemplateURL string // Optional. S3 object URL for the addons template.
AdditionalTags map[string]string // AdditionalTags are labels applied to resources in the workload stack.

// The target environment metadata.
ServiceDiscoveryEndpoint string // Endpoint for the service discovery namespace in the environment.
AccountID string
Region string
}

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

0 comments on commit 4a8f9cd

Please sign in to comment.