-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): impossible to use the same physical stack name for two stacks (under feature flag) #4895
Conversation
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this PR not include bump to the CX protocol?
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
…feature flag) Since we used the stack name as the template file name, if users wanted to use the same stack name in two environments, the emitted templates overwrote each other. Furthermore, the CLI used the artifact ID as the stack name, so this became a bit more complex. This means that `assembly.getStack()` is now ambiguous, so I renamed it `getStackByName` which fails if there are two stacks with the same name (legitimate) and added `getStackArtifact` which uses the artifact ID. The core library will effectively generate identical cloud assemblies if the stack name and artifact IDs are the same, and to ensure backwards compat, no existing tests have been changed (albeit it would have been more correct to replace all `getStackByName` with `getStackArtifact`, but effectively this is the same thing if they are equal). We want the template file name to use the artifact ID instead of the physical stack name but this can break users that depend on this behaviour (despite the fact that it's a formal API). To avoid this, we will only enable this new behaviour behind a [feature flag](#4925) which means that it will only be enabled for new projects created through `cdk init`, but old projects will still get the old behaviour. RFC for feature flags: #4925 Fixes #4412 BREAKING CHANGE: template file names in `cdk.out` for new projects created by `cdk init` will use `stack.artifactId` instead of the physical stack name to enable multiple stacks to use the same name. In most cases the artifact ID is the same as the stack name. To enable this fix for old projects, add the context key `@aws-cdk/core:enableStackNameDuplicates: true` in your `cdk.json` file.
d567535
to
36f0545
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
FWIW I had to update my classes that implement core.Stack because I just happened to be using the property artifact_id in my stacks and this change was breaking for me.
|
Legacy mode for #4895 still used the uniquely generated id instead of the stack name as the artifact ID in the cloud assembly. The implications were that even if users were not opted-in to the new behavior (through the feature flag), they could not use the stack name in the CLI because the stack artifact ID was still new. This fix ensures that if the feature flag is not enabled, the artifact ID itself uses the stack name, hence allowing users to query by stack name as long as they are not opted in to the new behavior. Fixes #4997
…4998) Legacy mode for #4895 still used the uniquely generated id instead of the stack name as the artifact ID in the cloud assembly. The implications were that even if users were not opted-in to the new behavior (through the feature flag), they could not use the stack name in the CLI because the stack artifact ID was still new. This fix ensures that if the feature flag is not enabled, the artifact ID itself uses the stack name, hence allowing users to query by stack name as long as they are not opted in to the new behavior. Fixes #4997
…4998) Legacy mode for #4895 still used the uniquely generated id instead of the stack name as the artifact ID in the cloud assembly. The implications were that even if users were not opted-in to the new behavior (through the feature flag), they could not use the stack name in the CLI because the stack artifact ID was still new. This fix ensures that if the feature flag is not enabled, the artifact ID itself uses the stack name, hence allowing users to query by stack name as long as they are not opted in to the new behavior. Fixes #4997
Since we used the stack name as the template file name, if users wanted to use the
same stack name in two environments, the emitted templates overwrote each other.
Apparently, the CLI used the artifact ID as the stack name, so this became a bit more complex.
This means that
assembly.getStack()
is now ambiguous, so I renamed itgetStackByName
which fails if there are two stacks with the same name (legitimate) and addedgetStackArtifact
which uses the artifact ID.The core library will effecitvely generate identical cloud assemblies if the stack name and artifact IDs are the same, and to ensure backwards compat, no existing tests have been changed (albeit it would have been more correct to replace all getStackByName with getStackArtifact, but effectively this is the same thing if they are equal).
We want the template file name to use the artifact ID instead of the physical stack name but this can break users that depend on this behavior (despite the fact that it's a formal API). To avoid this, we will only enable this new behavior behind a feature flag which means that it will only be enabled for new projects created through
cdk init
, but old projects will still get the old behavior.RFC for feature flags: #4925
Fixes #4412
BREAKING CHANGE: synthesized template file names for new projects created by
cdk init
will use the stack artifact ID instead of the physical stack name to enable multiple stacks to use the same name (in most cases artifact id and stack name are the same). This is enabled by inserting the feature flag@aws-cdk/core:enableStackNameDuplicates
undercontext
in newly generatedcdk.json
files.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license