Skip to content

Usage of cdk.StackProps.stackName when having multiple stacks with the same name #4412

@konstantinj

Description

@konstantinj

I'm having multiple stacks with the same name in different accounts/regions. Consider following example code:

const app = new cdk.App()
new cdk.Stack(app, 'test1', { stackName: 'test', env: { account: 'XXXXXXXXXXXX', region: 'eu-west-1' } })
new cdk.Stack(app, 'test2', { stackName: 'test', env: { account: 'XXXXXXXXXXXX', region: 'us-east-1' } })
  1. cdk synth is creating only one template for test2since it's the last one but the template is named test. test1 gets overwritten.

  2. cdk list also only lists the stack test and it's not possible to see the corresponding env

  3. cdk deploy can only deploy test2 as cdk deploy test

How is the stackName supposed to work? It looks like the stackName, when set, is treated as the main citizen here even though it's not unique.

Tested with cdk version 1.12.0

#4339 maybe something like visibleStackName makes more sense.

Metadata

Metadata

Assignees

Labels

@aws-cdk/coreRelated to core CDK functionalityguidanceQuestion that needs advice or information.in-progressThis issue is being actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions