cdk-lambda-llrt icon indicating copy to clipboard operation
cdk-lambda-llrt copied to clipboard

Add automatic entry lookup

Open guillaumefont opened this issue 1 year ago • 5 comments

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 !

guillaumefont avatar Jul 20 '24 15:07 guillaumefont

Hi @guillaumefont, LlrtFunction currently inherits NodejsFunction, so the feature just should work. Although I haven't used the feature, can you try it?

tmokmss avatar Jul 22 '24 07:07 tmokmss

Yes ! I tried it, here's the result :

image

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/[email protected][email protected][email protected][email protected]/node_modules/cdk-lambda-llrt/lib/llrt-function.create.ts, /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/cdk-lambda-llrt/lib/llrt-function.create.js, /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/cdk-lambda-llrt/lib/llrt-function.create.mjs, /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/cdk-lambda-llrt/lib/llrt-function.create.mts, /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/cdk-lambda-llrt/lib/llrt-function.create.cts or /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/cdk-lambda-llrt/lib/llrt-function.create.cjs
    at findEntry (/home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/[email protected][email protected]/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/[email protected][email protected]/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/[email protected][email protected][email protected][email protected]/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 

guillaumefont avatar Jul 22 '24 08:07 guillaumefont

Cannot find handler file /home/guillaume/Code/sollar-app/platform/packages/infra/platform/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/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.

tmokmss avatar Jul 22 '24 08:07 tmokmss

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.

tmokmss avatar Jul 28 '24 03:07 tmokmss

Thanks for the investigation. I'll specify the entry point manually in the mean time !

guillaumefont avatar Jul 28 '24 08:07 guillaumefont