(aws-cdk): asset bundling skipped when using --exclusively option
See original GitHub issueAsset bundling is currently broken when using the --exclusively
option during deploy.
In our case we have an aws-lambda-nodejs
with forceDockerBuild set to true (but it shouldn’t matter).
However, due to the following check the bundling never happens when e.g. running cdk deploy --exclusively 'MyStack'
-
as in it will skip the bundling step completely.
Concretely, this minimatch evaluates to false
for any given stack name, except when using --all
which evaluates to the wildcard *
satisfying anything.
https://github.com/aws/aws-cdk/blob/9417b0211eb2939f5a853751333f7941d9dd99f8/packages/%40aws-cdk/core/lib/asset-staging.ts#L164
That is because Stack.of(this).stackName
is not resolved at this point. The screenshot shows the output of running with --all
(bundlingStacks contains [*]
) against the unresolved stack name:
Tested on Linux and Windows and CDK 1.88.
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:11 (5 by maintainers)
Top GitHub Comments
I added more stacks and lambdas to the example repository. Some of my observations while debugging:
Produces not wanted Lambda asset path pointing to the root folder of the project:
Targeting manifest in
cdk.out/assembly
folder produces right asset path when using-e
tag. To update templates, I used synth commands, which then also bundles other lambdas in the other stacks during synth, this is unwanted and in large projects takes a lot of time.Using
-e
tag with synth commands only bundles lambdas from wanted stack, but it also points lambda asset path to project root.This known issue is preventing the usage of new
--hotswap
feature with multi stack projects.Can confirm this bug still exists with the -e flag. I have a similar setup with multiple stacks. The entry for the NodeJsFunction is the default one, aka
My suspicion is, that the
cdk deploy -e stackName
internally has a wrong context and therefore adds the root of the project as the asset.CDK version: 1.123.0
What’s the alternative/workaround?