-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
core: 'cdk synth' always synthesizes every stack #28136
Comments
Yes, this seems to be a bug. |
You can try e.g. |
Indeed, through the usage of the |
the I have a simple stack called Im using cdk 2.139.1 (build b88f959) Once I ran |
edit: it is actually building all my stacks |
@AllanOricil That said, I sometimes add an environment variable to entirelly include/exclude certain stacks, that do not have dependencies with each other, from // bin/cdk.ts
if (process.env.ENV=='prod') {
new SomeStack(app, "ProdStack");
} else {
new SomeStack(app, "DevStack");
} this allows you to synth only the required stacks by modifying the cdk deploy command: # build and deploy only DevStack
npx cdk deploy --all
# build and deploy only ProdStack
ENV=prod npx cdk deploy --all |
So there is some kind of bug because the bundling steps are also running 😅 |
this is how the bundling: {
sourceMap: true,
nodeModules: ["winston", "@sentry/serverless"],
externalModules: ["aws-sdk", "@aws-sdk"],
user: "root",
forceDockerBundling: true,
dockerImage: cdk.DockerImage.fromBuild(
DEFAULT_DOCKER_BUILD_IMAGES_PATH,
{
file: "ci.Dockerfile",
},
),
commandHooks: {
beforeBundling(i: string, o: string): string[] {
return ['echo "BEFORE BUNDLING"'];
},
beforeInstall(i: string, o: string): string[] {
return ['echo "BEFORE INSTALL"'];
},
afterBundling(i: string, o: string): string[] {
return [
'echo "AFTER BUNDLING"',
`cp ${i}/.sentryclirc .`,
`sentry-cli sourcemaps inject --org journeylab --project create-route-53-records .`,
`sentry-cli sourcemaps upload --org journeylab --project create-route-53-records .`,
`rm .sentryclirc`,
];
},
},
},
}, |
@tmokmss evidence to show that As you can see, cdk triggered the bundling phase of a stack that I did not even asked it to deploy when running |
|
This looks like the same issue as #6743. |
That issue has more upvotes, so I'm closing this one in favor of the other one - please continue the discussion there. |
|
1 similar comment
|
Describe the bug
If the command
cdk synth 'Dev/*'
is executed. All stacks are synthesized.The same output is created in the
cdk.out
directory if a concrete stack is synthesizedcdk synth 'Dev/ExampleStack'
.Expected Behavior
Only the
Dev
environment stacks should be synthesized. Only theDev
environment lambda assets should be created.Current Behavior
All stacks are synthesized. All lambda assets are created.
Reproduction Steps
Create a project with the following files and execute
cdk synth 'Dev/*'
.cdk/app.ts
cdk/example-stack.ts
shared/environment.ts
src/example-handler.ts
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.110.1
Framework Version
2.110.1
Node.js Version
20.9.0
OS
WSL2 - Ubuntu 22.04.2 LTS
Language
TypeScript
Language Version
5.2.2
Other information
No response
The text was updated successfully, but these errors were encountered: