DEV Community

Sriram Narasimhan
Sriram Narasimhan

Posted on

1

Lambda Layers for NodeJS - An Example

GitHub logo nsriram / aws-lambda-layer-example

aws lambda layer example

Lambda Layers for NodeJS - An Example

This article outlines the steps involved in building a node js lambda using lambda layers for library dependencies, using AWS CLI.

The example will build a lambda function that will return current time using momentjs library. The lambda will not bundle momentjs via package.json, node_modules, but will use momentjs via lambda layers.

Following are assumed to be available on your computer.

  1. AWS Account
  2. IAM Role to manage and execute lambda functions
  3. AWS CLI version 1.16.69

1 : Create and publish momentjs lambda layer.

What is a lambda layer (Source: AWS Docs) : A layer is a ZIP archive that contains libraries, a custom runtime, or other dependencies. With layers, you can use libraries in your function without needing to include them in your deployment package.

1.1 Create an empty nodejs project.

> cd ~
> mkdir momentjs-lambda-layer
> cd

Top comments (0)

Image of Stellar post

🚀 Stellar Dev Diaries Series: Episode 1 is LIVE!

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay