-
Notifications
You must be signed in to change notification settings - Fork 4.5k
(aws-lambda-nodejs): bundling logLevel property is ignored when nodeModules are required #18383
Description
What is the problem?
When a stack contains a NodejsFunction construct requiring node modules and with a log level in the bundling configuration, every cdk command in the same app starts the asset bundling ignoring that logging configuration.
Reproduction Steps
Create a sample application and a stack containing this resource.
new NodejsFunction(this, "MyNodejsFunction", {
bundling: {
nodeModules: ["request", "request-promise"],
logLevel: LogLevel.SILENT
},
entry: "path/to/lambda/code/index.js",
runtime: Runtime.NODEJS_14_X
});Now run whatever cdk command on that app.
What did you expect to happen?
Every command in the bundling phase should respect the specified log level.
What actually happened?
Commands like cdk ls, cdk diff, cdk deploy produce a log output even if the log level is set to LogLevel.SILENT. It seems that only the esbuild command is provided with the log level, whereas subsequent commands in the bundling chain such as npm ci run with no logging configuration.
CDK CLI Version
2.5.0
Framework Version
1.125.0
Node.js Version
v16.13.0
OS
Linux Mint 20.3
Language
Typescript
Language Version
4.1.3
Other information
I managed to temporarily work around the bug by manually setting the log level for npm ci command adding --loglevel=silent here in my compiled module under node_modules/@aws-cdk/aws-lambda-nodejs/lib/package-manager.js.
I guess this is a small effort task, as one shold just propagate the configured bundling log level to the PackageManager class and use that same value to configure the log level also for other commands than esbuild (as done here).