A custom runtime for AWS Lambda to execute functions in Node.js 10.x or 11.x
Save as index.js
:
exports.handler = async(event, context) => {
console.log(`Hi from Node.js ${process.version} on Lambda!`)
console.log(`There is ${context.getRemainingTimeInMillis()}ms remaining`)
return event
}
Then bundle up into a zipfile – this is your function bundle:
zip -yr lambda.zip index.js # add node_modules too if you have any
Create a new Lambda function and choose the custom runtime option.
Select your lambda.zip
as the "Function code" and make the handler "index.handler".
Then click on Layers and choose "Add a layer", and "Provide a layer version ARN" and enter the following ARN:
arn:aws:lambda:us-east-1:553035198032:layer:nodejs10:1
Or use this link and pick your function from the "Function name" auto-suggest.
Then save your lambda and test it with a test event!
Node.js version | ARN |
---|---|
10.14.2 | arn:aws:lambda:<region>:553035198032:layer:nodejs10:2 |
11.4.0 | arn:aws:lambda:<region>:553035198032:layer:nodejs11:3 |
Node.js version | ARN |
---|---|
10.14.1 | arn:aws:lambda:<region>:553035198032:layer:nodejs10:1 |
11.3.0 | arn:aws:lambda:<region>:553035198032:layer:nodejs11:1 |
- This is a no-batteries-included runtime – you'll need to zip up any
node_modules
dependencies, includingaws-sdk
with your lambda function - Cold start overhead of ~270ms for Node.js 10.x and ~290ms for 11.x – this is due to Node.js' increasingly slow startup time, but they're working on it!