aws-lambda-extensions icon indicating copy to clipboard operation
aws-lambda-extensions copied to clipboard

Nodejs extension example with its own runtime

Open neeleshsaxena opened this issue 3 years ago • 4 comments

Hey folks, is there a way to bundle node runtime with the nodejs-example-logs-api-extension repo. I would like this layer to be totally self sufficient, so that it can be used by any lambdas that may have different runtimes. I know that is possible according to the docs, but I'm unable to do so. Any pointers would be greatly appreciated.

If I try and deploy a node layer with say Java runtime lambda, I get these errors: nodejs-log-api-extension launching extension /usr/bin/env: node: No such file or directoty

neeleshsaxena avatar Mar 24 '22 19:03 neeleshsaxena

@neeleshsaxena : Are you trying to add different run times like below : Or wanting to use this extension with Lambda function that has a different runtime apart from nodejs ? aws lambda publish-layer-version \ ─╯ --layer-name "nodejs-example-extension"
--region us-east-1
--zip-file "fileb://extension.zip"
--compatible-runtimes nodejs12.x nodejs14.x nodejs16.x

agnel0410 avatar Jul 03 '22 15:07 agnel0410

Checking in on this. Are you placing your packaged node folder in a location that the runtime/extension can find? Are you amending https://github.com/aws-samples/aws-lambda-extensions/blob/main/nodejs-example-logs-api-extension/extensions/nodejs-example-logs-api-extension#L11 to launch node and then the .js file of the extension?

julianwood avatar Jul 03 '22 20:07 julianwood

@agnel0410 The latter -- I'm trying to use this extension (node) with a Lambda function which has JAVA runtime.

@julianwood I might have placed the packaged modules incorrectly.

Ideally it should have worked, right? I should be able to use this node extension on a JAVA Lambda runtime, yeah? As long as I've specified the runtime for my layer in the template?

neeleshsaxena avatar Jul 08 '22 19:07 neeleshsaxena

@neeleshsaxena Hi, I try to use this runtime for golang or nodejs. But it doesn't work. I added the compatibility "nodejs16.x", but no success. Did you solve the issue with other runtime?

amirkkn avatar Oct 18 '22 13:10 amirkkn

When you specify the compatible runtimes in the layer, its just a label so that managed runtime users know whether they can use your extension. It doesn't make any binaries compatible with any runtimes. Your node extension needs to be completely self sufficient with the node binaries bundled together. Your bootstrap file needs to then launch node. The Java runtime will not be aware its interacting with a node extension.

julianwood avatar Oct 24 '22 20:10 julianwood

Closing as functionality explained

julianwood avatar Dec 14 '22 22:12 julianwood