Open guillaumefont opened 3 months ago
Hi @guillaumefont, LlrtFunction currently inherits NodejsFunction, so the feature just should work. Although I haven't used the feature, can you try it?
Yes ! I tried it, here's the result :
const listAppFunction = new LlrtFunction(this, `create`, {
runtime: Runtime.NODEJS_20_X,
architecture: Architecture.ARM_64,
environment: {
TABLE_NAME: props.table.tableName,
},
});
And I get the following error :
Error: Cannot find handler file /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/cdk-lambda-llrt@0.0.11_aws-cdk-lib@2.149.0_constructs@10.3.0__constructs@10.3.0/node_modules/cdk-lambda-llrt/lib/llrt-function.create.ts, /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/cdk-lambda-llrt@0.0.11_aws-cdk-lib@2.149.0_constructs@10.3.0__constructs@10.3.0/node_modules/cdk-lambda-llrt/lib/llrt-function.create.js, /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/cdk-lambda-llrt@0.0.11_aws-cdk-lib@2.149.0_constructs@10.3.0__constructs@10.3.0/node_modules/cdk-lambda-llrt/lib/llrt-function.create.mjs, /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/cdk-lambda-llrt@0.0.11_aws-cdk-lib@2.149.0_constructs@10.3.0__constructs@10.3.0/node_modules/cdk-lambda-llrt/lib/llrt-function.create.mts, /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/cdk-lambda-llrt@0.0.11_aws-cdk-lib@2.149.0_constructs@10.3.0__constructs@10.3.0/node_modules/cdk-lambda-llrt/lib/llrt-function.create.cts or /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/cdk-lambda-llrt@0.0.11_aws-cdk-lib@2.149.0_constructs@10.3.0__constructs@10.3.0/node_modules/cdk-lambda-llrt/lib/llrt-function.create.cjs
at findEntry (/home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/aws-cdk-lib@2.149.0_constructs@10.3.0/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:5239)
at new NodejsFunction (/home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/aws-cdk-lib@2.149.0_constructs@10.3.0/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:1865)
at new LlrtFunction (/home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/cdk-lambda-llrt@0.0.11_aws-cdk-lib@2.149.0_constructs@10.3.0__constructs@10.3.0/node_modules/cdk-lambda-llrt/lib/llrt-function.js:17:9)
at new AppsConstruct (/home/guillaume/Code/sollar-app/platform/packages/infra/platform/dist/api/apps/index.js:12:35)
at new CommonStack (/home/guillaume/Code/sollar-app/platform/packages/infra/platform/dist/common.js:25:9)
at Object.<anonymous> (/home/guillaume/Code/sollar-app/platform/packages/infra/platform/dist/index.js:24:1)
at Module._compile (node:internal/modules/cjs/loader:1504:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1588:10)
at Module.load (node:internal/modules/cjs/loader:1282:32)
at Module._load (node:internal/modules/cjs/loader:1098:12)
When I simply replace with a Node function it works :
const createAppFunction = new NodejsFunction(this, `create`, {
runtime: Runtime.NODEJS_20_X,
architecture: Architecture.ARM_64,
environment: {
TABLE_NAME: props.table.tableName,
},
});
Bundling asset sollar-app-local-common/apps/create/Code/Stage...
cdk.out/bundling-temp-f9c7bd28734f7566002a38798b4932afbefd4f7853575510b4d8b62e4e778644/index.js 362b
Cannot find handler file /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/cdk-lambda-llrt@0.0.11_aws-cdk-lib@2.149.0_constructs@10.3.0__constructs@10.3.0/node_modules/cdk-lambda-llrt/lib/llrt-function.create.ts
Thanks, hmm so it is somehow searching for an entry file in a wrong directory. I'll look at this, thanks.
It turns out that the finding logic is hard coded here, and currently we don't have any way to change this behavior from an inheriting class.
We need to change the upstream implementation to allow to modify this behavior.
Thanks for the investigation. I'll specify the entry point manually in the mean time !
Hi,
Thanks for your construct that is awesome !!
There is a handy feature of NodejsFunction that I would like to use with your LlrtFunction is automatic entry lookup, documented here.
Thanks !