- create a folder in your local machine called nodejs
- put your "shared" logic in that folder like /nodejs/shared.js
- you can zip this nodejs folder and upload as a layer
- in your lambda code require the shared.js as
const shared = require('/opt/nodejs/shared.js')
Links:
- Lambda layers: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html
- Detailed guide: https://explainexample.com/computers/aws/aws-lambda-layers-node-app
- Using layers with SAM: https://docs.aws.amazon.com/serverlessrepo/latest/devguide/sharing-lambda-layers.html
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with node.js › working with layers for node.js lambda functions
Working with layers for Node.js Lambda functions - AWS Lambda
Create the layer in Lambda. Add the layer to your functions. ... To create a layer, bundle your packages into a .zip file archive that meets the following requirements: Build the layer using the same Node.js version that you plan to use for the Lambda function.
node.js - How to share my own custom fucntions on AWS lambda nodejs - Stack Overflow
I Currently have a project in AWS with several lambda functions, most of the functions in NodeJS, I want to know if is there a way to create a lambda layer with my own code functions that I use in different lambdas without publish it in npm, I already search in old questions in stack question-1 ... More on stackoverflow.com
How to upload a Lambda function with Node.js SDKs and dependencies?
Try this search for more information on this topic. Comments, questions or suggestions regarding this autoresponse? Please send them here . I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
How to use Sharp in AWS Lambda function? I keep getting errors. (node.js, for image resizing)
Can you provide details about how you’re building and deploying the function and layer. Most likely is that it’s a problem with your build step. More on reddit.com
Upgrading NODE in AWS 14 to 20.
First upgrade all the tests to run in Node v20. If those pass, you should be good to go. You do have tests, right? More on reddit.com
Videos
20:42
Managing dependencies using AWS Lambda Layers with NodeJS and AWS ...
10:21
Speeding up the AWS Lambda layer building - YouTube
38:48
Lambda Layers: Using layers to manage code dependencies in serverless ...
04:08
AWS Lambda Layers with Node JS (2020) - YouTube
09:22
All New Lambda Layers Tutorial: Save Space and Remove Common Code ...
19:18
AWS Lambda Layers - How to use them in Lambda Functions - YouTube
Danielleheberling
danielleheberling.xyz › blog › lambda-layer-example
Create Your Own Lambda Layer with NodeJS | Danielle's Blog
January 22, 2020 - const palindrome = require("/opt/nodejs/palindrome") exports.handler = async (event, context) => { // Log the event argument for debugging and for use in local development. console.log(JSON.stringify(event, undefined, 2)) const words = "This string should be reversed" const response = palindrome(words) return { statusCode: 200, headers: {}, response: JSON.stringify(response), } } The important thing to note here is the first line where we require from /opt/nodejs, otherwise you can use your library like you normally would when developing outside of Lambda. Once deployed, go ahead and invoke the function. You should see the original string reversed in the function response. Check out the full code example in this repo. All of the official documentation from AWS about Lambda layers can be found here.
Explainexample
explainexample.com › computers › aws › aws-lambda-layers-node-app
Use AWS Lambda layers for your Node.js app
In this section, we will set up ... this section, you will be in a position to create your own serverless Nodejs app. Step 1 - Create a new Lamda Layer using the AWS Lambda console....
Lightrun
docs.lightrun.com › lambda › nodejs-layers
Install Lightrun with Lambda Layers - Lightrun Documentation
September 6, 2023 - Click Create Layer. Specify a name for the new Lambda Layer. Upload the generated layers.zip file. Select the compatible architecture and runtime for your .zip file (we will be using the x86_64 architecture and Node.js 24.x as our preferred ...
GitHub
github.com › aws-samples › aws-lambda-layers-aws-sam-examples
GitHub - aws-samples/aws-lambda-layers-aws-sam-examples: This example application shows how to build AWS Lambda Layers using Node.js and the AWS Serverless Application Model. Questions? @jbesw. · GitHub
January 12, 2026 - This example application shows how to build AWS Lambda Layers using Node.js and the AWS Serverless Application Model. Questions? @jbesw. - aws-samples/aws-lambda-layers-aws-sam-examples
Starred by 29 users
Forked by 15 users
GitHub
github.com › tobilg › nodejs-lambda-layer-builder
GitHub - tobilg/nodejs-lambda-layer-builder: Build custom AWS Lambda layers for Node
Builds either a zip file or a raw directory strucutre (e.g. if you want to use frameworks like Serverless for packaging) containing Node dependencies and places the libraries into the proper directory structure for lambda layers · Ensures compiled libraries are compatible with Lambda environment by using the lambci/lambda Docker container that mimics the lambda runtime environment · Allows specifying AWS Lambda supported Node versions: 8.10, 10.x and 12.x · Automatically searches for package.json file in several locations:
Author tobilg
freeCodeCamp
freecodecamp.org › news › lambda-layers-2f80b9211318
How to build and use a Layer for your AWS Lambdas
January 16, 2019 - I like to have all my layers in a folder next to my Lambdas folder. We can create a new layer folder called DemoLayer which needs to have a folder for the runtime that it is going to use. For this example, we are going to use nodejs, so we create that folder. ... Using our terminal, we can navigate to the DemoLayer folder and initialize NPM. ... Accept all the default values in the NPM setup, and you’ll have the package.json ...
AWS re:Post
repost.aws › knowledge-center › lambda-layer-aws-sdk-latest-version
Integrate the AWS SDK for JavaScript into a Node.js Lambda function | AWS re:Post
April 28, 2025 - Choose the Custom Layers dropdown list, and then choose your custom layer. Choose Add. Complete the steps in the (Optional) Confirm the AWS SDK version that your function uses section to invoke your function. The function returns the version of the AWS SDK that it uses. Best practices for working with AWS Lambda functions · How do I build a Lambda deployment package for Node.js? How can I create a layer for my Lambda Python function?
AWS Amplify
docs.amplify.aws › gen1 › javascript › build-a-backend › functions › layers
Reuse code and assets using layers - JavaScript - AWS Amplify Gen 1 Documentation
April 29, 2024 - We recommend you to create a dev environment and test the functions inside the AWS Lambda console. The general workflow breaks down into the following steps: ... Next, you'll be guided through a workflow to provide a layer name, and select a supported runtime. Currently Amplify CLI provides NodeJS or Python runtime support for layers.
GitHub
github.com › nsriram › aws-lambda-layer-example
GitHub - nsriram/aws-lambda-layer-example: aws lambda layer example
December 5, 2018 - This article outlines the steps involved in building a node js lambda using lambda layers for library dependencies, using AWS CLI.
Author nsriram