You can deploy your Lambda function code as a container image. AWS provides the following resources to help you build a container image for your Node.js function:
-
AWS base images for Lambda
These base images are preloaded with a language runtime and other components that are required to run the image on Lambda. AWS provides a Dockerfile for each of the base images to help with building your container image.
AWS provides base images for the x86_64 architecture for all supported .NET runtimes, and for the arm64 architecture for the .NET Core 3.1 and .NET 6.0 runtimes.
-
Open-source runtime interface clients (RIC)
If you use a community or private enterprise base image, you must add a Runtime interface client to the base image to make it compatible with Lambda.
-
Open-source runtime interface emulator (RIE)
Lambda provides a runtime interface emulator for you to test your function locally. The base images for Lambda and base images for custom runtimes include the RIE. For other base images, you can download the RIE for testing your image locally.
The workflow for a function defined as a container image includes these steps:
-
Build your container image using the resources listed in this topic.
-
Upload the image to your Amazon ECR container registry. See steps 7-9 in Create image.
-
Create the Lambda function or update the function code to deploy the image to an existing function.
Topics
- AWS base images for Node.js
- Using a Node.js base image
- Node.js runtime interface clients
- Deploy the container image
AWS provides the following base images for Node.js:
Tags | Runtime | Operating system | Dockerfile |
---|---|---|---|
14 | NodeJS 14.x | Amazon Linux 2 | Dockerfile for Node.js 14.x on GitHub |
12 | NodeJS 12.x | Amazon Linux 2 | Dockerfile for Node.js 12.x on GitHub |
10 | NodeJS 10.x | Amazon Linux 2 | Dockerfile for Node.js 10.x on GitHub |
Docker Hub repository: amazon/aws-lambda-nodejs
Amazon ECR repository: gallery.ecr.aws/lambda/nodejs
For instructions on how to use a Node.js base image, choose the usage tab on AWS Lambda base images for Node.js in the Amazon ECR repository.
The instructions are also available on AWS Lambda base images for Node.js in the Docker Hub repository.
Install the runtime interface client for Node.js using the npm package manager:
npm install aws-lambda-ric
For package details, see Lambda RIC on the npm website.
You can also download the Node.js runtime interface client from GitHub.
For a new function, you deploy the Node.js image when you create the function. For an existing function, if you rebuild the container image, you need to redeploy the image by updating the function code.