aws-samples / aws-lambda-extensions

A collection of sample extensions to help you get started with AWS Lambda Extensions
MIT No Attribution
445 stars 146 forks source link

Nodejs extension example with its own runtime #69

Closed neeleshsaxena closed 1 year ago

neeleshsaxena commented 2 years ago

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

agnel0410 commented 2 years ago

@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

julianwood commented 2 years ago

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?

neeleshsaxena commented 2 years ago

@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?

amirkkn commented 2 years ago

@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?

julianwood commented 2 years ago

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 commented 1 year ago

Closing as functionality explained