aws-cdk: [@aws-cdk/aws-lambda-nodejs] 'Cannot find entry file' when using a JSII construct that includes a lambda_nodejs.NodejsFunction
I’m trying to create a reusable library to handle ECR image scan results. The code is available at https://github.com/markusl/cdk-ecr-image-scan-handler
After publishing the generated library (using projen & JSII tools) to NPM and using it from another AWS CDK project I get the following, not very useful error message:
$ npm run build && cdk synth
> aws-cdk-pipelines-test@0.1.0 build aws-cdk-pipelines-test
> tsc
Cannot find entry file.
Subprocess exited with error 1
The directory structure of the imported NPM package under node_modules looks ok to me:
cdk-ecr-image-scan-handler/lib/index.js
cdk-ecr-image-scan-handler/lib/index.d.ts
cdk-ecr-image-scan-handler/lib/index.handler.js
cdk-ecr-image-scan-handler/lib/index.handler.d.ts
@jogold already provided some input for the source module setup which apparently is supposed to work like this:
new lambda_nodejs.NodejsFunction(this, 'handler', {
runtime: lambda.Runtime.NODEJS_12_X,
minify: true,
role: lambdaRole,
functionName: componentName,
description: 'Handler for ECR Image Scan results',
environment: {
FROM_ADDRESS: props.fromAddress,
TO_ADDRESS: props.toAddress,
},
});
Please let me know if there are any configuration errors in the project. I was looking for a reference setup but did not find one yet.
What did you expect to happen?
I would expect the Lambda function to be packaged correctly.
What actually happened?
I received the error.
Environment
- CLI Version : 1.59.0
- Framework Version: 1.59.0
- Node.js Version: v12.14.1
- OS : macOS
- Language (Version):
Other
This is 🐛 Bug Report
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (17 by maintainers)
@jogold we are also considering creating some internal libraries/tooling which require the bunding functionality. If we get this working 😃 I’d like to start with a simple example first to get the baseline configuration working.
Would you be able to provide a complete JSII module with an example setup using
NodejsFunctionbundling? That would be a good starting point for us and others as well.@markusl switching to local bundling in your repo (https://github.com/markusl/cdk-ecr-image-scan-handler/pull/28, https://github.com/markusl/cdk-ecr-image-scan-handler/pull/29) made it work in your GitHub action.
It looks like Docker-in-Docker with volume mounts inside a GitHub action is problematic but we now have local bundling.
Regarding the
Cannot find entry fileI think we can improve the automatic entry finding in the CDK. There’s something to do with the source map.