DEV Community

loading...

Lambda Layers for NodeJS - An Example

sriramn78 profile image Sriram Narasimhan ・1 min read

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




Discussion (0)

pic
Editor guide