A template for creating a lambda with serverless on AWS with babel7 with the option to add a lambda layer
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
tests
.babelrc
.eslintrc.json
.gitignore
.prettierrc
LICENSE
README.md
addLayer.sh
handler.js
package.json
serverless.yml
setUp.sh
webpack.config.js
yarn.lock

README.md

Serverless Lambda Template with optional Layer support

This repo is derived from AnomalyInnovations/serverless-nodejs-starter

It provides the set up to create an AWS lambda with serverless using babel 7 that is set up to use layers

  • jest, eslint and prettier configured

You can create a layer via https://github.com/robcronin/serverless-layer-template

For an example repo of a lambda with a layer created with these templates see here

Requirements

Install

sls install --url https://github.com/robcronin/serverless-lambda-with-optional-layer-template --name [NAME_OF_YOUR_LAMBDA]

or

git clone https://github.com/robcronin/serverless-lambda-with-optional-layer-template
  • cd [NAME_OF_YOUR_LAMBDA]
  • yarn
  • ./setUp.sh - answer the prompts

Modify

Edit the code in handler.js as required

By default it is a simple hello function

Deploy

  • yarn deploy
    • This will run sls deploy assuming your aws credentials are set up

Local usage

  • Running sls offline start will allow you to ping localhost:3000/hello

Tests

yarn test will run:

  • yarn lint
  • yarn jest

Adding a layer

  • If you created a layer with https://github.com/robcronin/serverless-layer-template you can use ./addLayer.sh to set up your lambda to use it
  • In your layer repo you can use ./local.sh to create a local version of your lambda at /opt or use yarn watch to watch any changes and update your local version as you develop your layer