Serverless Plugin Layer Manager

homepage icon https://github.com/henhal/serverless-plugin-layer-manager
Follow @henhal

Tracked

NPM Downloads Last Month
3063
Issues
0
Stars
0
Forks
0
Watchers
0
Watch Star Fork Issue Download License NPM Build Status Coverage Status Contributors

Repo README Contents:

serverless-plugin-layer-manager

NPM version Build Status

Plugin for the Serverless framework that offers improved AWS Lambda layer management.

The Serverless framework supports AWS Lambda layers, but there are some shortcomings:

This plugin fixes all these problems by automatically adding hooks to invoke npm install on each declared Node.JS layer, and by transforming the generated CloudFormation template to export the layers and to properly reference the versioned layers from functions.

Installation:

npm install --save-dev serverless-plugin-layer-manager

serverless.yml:

...
plugins:
  - serverless-plugin-layer-manager

That’s it! You may now reference your layers from functions in the same file like

layers:
  lib:
    path: lib
    name: dev-foo-lib
    description: My library
    retain: true
    
functions:
  hello:
    handler: index.handler
    layers:
      # Note the reference being the TitleCase representation of the layer id followed by "LambdaLayer"
      - {Ref: LibLambdaLayer}

The lib layer will be installed and its node_modules packaged into the artifact, and the function will use the layer.

You may customize the features by adding a layerConfig object under custom, supporting the following properties:

custom:
  layerConfig:
    installLayers: <boolean>
    exportLayers: <boolean>
    upgradeLayerReferences: <boolean>
    exportPrefix: <prefix used for the names of the exported layers>

By default, all config options are true and the exportPrefix is set to ${AWS:StackName}-.