Run Every Node.js Version in AWS Lambda

Hero Image

So you want to create an AWS Lambda function running the latest version of Node.js? Maybe you want to use the new fetch() API? Or need that one feature of the latest V8? Or just deploy your next serverless app with the latest and greatest version?

Whatever the reason, you have a small problem - Amazon Web Services usually takes some time before adding support for new versions of Node.js. As of this writing, Node.js v18 is about to ship, and the latest version supported by AWS is v14.

Enter fusebit/everynode. Everynode allows you to:

  • Run any version of Node.js in AWS Lambda,
  • in any commercial AWS region,
  • within hours of the release of that Node.js version.
Run Any Node.js Version in AWS Lambda

Quickstart

Let's deploy a Hello, World Lambda function using Node.js 17.5.0 to us-west-1.

First, create the Lambda deployment package:

cat > function.js << EOF
exports.handler = (event, context, callback) => {
callback(null, {
message: "Hello from Node " + process.version
});
};
EOF


zip function.zip function.js

Next, create the hello17 Lambda function in us-west-1 that uses a custom Lambda runtime with Node.js v17.5.0 provided by Fusebit:

# The ARN of the custom runtime layer containg Node.js 17.5.0 for us-west-1
LAYER=arn:aws:lambda:us-west-1:072686360478:layer:node-17_5_0:6

# Create a Lambda function using Node.js 17.5.0
aws lambda create-function --function-name hello17 \
--layers $LAYER \
--region us-west-1 \
--zip-file fileb://function.zip \
--handler function.handler \
--runtime provided
--role {iam-role-arn}

Last, call the function:

aws lambda invoke --function-name hello17 response.json
cat response.json

And voila, welcome to Node.js v17.5.0 function successfully deployed to AWS Lambda:

{ "message": "Hello from Node v17.5.0" }

Read more at fusebit/everynode to discover how to create a Lambda function using any other version of Node.js or region!

How does it work?

The fusebit/everynode project provides pre-built AWS Lambda layers that contain custom AWS Lambda runtimes for every Node.js version >=11 running on Amazon Linux 2 in all commercial AWS regions. The layers are built and hosted by Fusebit for all developers to use.

We constantly monitor for new Node.js releases and generally provide new AWS Lambda runtime layers in all AWS regions within six hours after release.

What is Fusebit?

Fusebit is a code-first integration platform that helps developers add integrations to their apps. The ability to run any version of Node.js in AWS Lambda is something we had to solve ourselves internally and decided to share the solution with all developers, free forever.

Check out the project at fusebit/everynode to get involved, experiment, or report an issue.

Follow us on Twitter @fusebitio for announcements about the availability of new Node.js versions in AWS Lambda.


ArrowPrevious
NextArrow

Related Content

14 April 2022
EveryAuth: The Easiest Way For Your App To Access APIs Like Slack, Salesforce, or Github

EveryAuth handles OAuth flow to external services and manages your users’ credentials so that you can focus on your integration logic rather than busywork.

23 February 2022
Node.js Adds Support for Direct Registry-less HTTPS Imports

Node is planning to introduce support for HTTPS imports in Node 18 - a feature that enables you to use urls to directly import modules over HTTPS into your project.

24 January 2022
Run Node.js from Google Sheets

Import data from any API or data source to Google Sheets using Node.js, NPM, and Fusebit Connectors.