I have two projects, A and B (frontend and backend). Both of these projects deploy resources to a single AWS Account using AWS CDK. Each project uses Stacks to declare AWS resources:
// Project's A stack
new PipelineStack(scope, "<LOGICAL_ID>", props)
// Project's B stack
new PipelineStack(scope, "<LOGICAL_ID>", props)
I noticed that if you name two stacks with the same <LOGICAL_ID>
in different projects and deploy the code to shared AWS account, it overrides the stack of the other project (though I might be wrong).
So, are there any best practices or guidelines on how to name these stacks to prevent accidental overwrite?
2
Answers
My current approach involves wrapping all stack logical IDs using a custom function
If you’re really set on not changing your stack ID then you can use the .stackName property to override it. However, in your case that doesn’t really buy you much so just keep with the suffix method you’ve got.