Skip to content

A custom runtime for AWS Lambda to execute functions in Node.js v10.x or v11.x

License

Notifications You must be signed in to change notification settings

ReppHealth/node-custom-lambda

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js 10.x and 11.x for AWS Lambda

A custom runtime for AWS Lambda to execute functions in Node.js 10.x or 11.x

Getting Started

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.

Create lambda

Select your lambda.zip as the "Function code" and make the handler "index.handler".

Function code

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.

Add a layer

Then save your lambda and test it with a test event!

Test event output

Current Version ARNs

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

Previous Version ARNs

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

Things to be aware of

  • This is a no-batteries-included runtime – you'll need to zip up any node_modules dependencies, including aws-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!

About

A custom runtime for AWS Lambda to execute functions in Node.js v10.x or v11.x

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 65.1%
  • JavaScript 18.4%
  • Dockerfile 16.5%