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
node_modules, but will use momentjs via lambda layers.
Following are assumed to be available on your computer.
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