-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
When deploying using all of the following, the asset for the Lambda function is a zip of the root of the project, not the asset as expected:
- a stack containing a
@aws-cdk/aws-lambda-nodejs.NodejsFunctionLambda function - attaching the stack I'm deploying to a
@aws-cdk/core.Stagerather than to a@aws-cdk/core.App - using the
-e(exclusive) flag to the synth or deploy commands
Based on my testing, not doing any one of these things results in the expected behaviour where the asset is the expected thing.
See dummy project here https://github.com/isotoma/cdk-nodejsfunction-asset-size-debugging to show my testing and why I have ended up where I have.
I happened to find this because a real project uploaded the whole project root as the source asset for the Lambda, which ended up being over Lambda's 250MB limit.
Reproduction Steps
See https://github.com/isotoma/cdk-nodejsfunction-asset-size-debugging, and the branches listed in the readme, and the behaviour shown in the Github CI.
What did you expect to happen?
- Use of the
-eCLI flag should not affect the built asset - Use of a
Stageshould not affect the built asset
What actually happened?
- I would not expect the whole project directory to ever be zipped and uploaded to the assets bucket.
Environment
- CDK CLI Version : 1.110.1 (also affects >= 1.102.0, because that's where the feature to deploy stacks from stages arrived, see feat(cli): directly deploy stacks in nested assemblies #14379. Believe earlier versions did not have this feature.)
- Framework Version: 1.110.1
- Node.js Version: v14.17.0
- OS: Linux
- Language (Version): Typescript 4
Other
I am mildly suspicious of switches in context in cdk.json, but for no real reason, and have no guesses as to what might actually be wrong.
Happy to try other things with my dummy project if useful.
This is 🐛 Bug Report