Skip to content

pandomic/serverless-offline-variables

Repository files navigation

serverless-offline-variables

About

serverless-offline-variables is a lightweight plugin to replace ${cf:}, ${s3:}, ${ssm:} and ${env:} parameters during the local (offline) runs, which can be very useful when testing microservices in isolation.

Installation

Use yarn or npm to add the plugin to your package dependecies:

npm install --save-dev serverless-offline-variables

or

yarn add serverless-offline-variables --dev

Usage

  1. Add plugin to you serverless plugins
plugins:
  ...
  - serverless-offline-variables
  1. Configure plugin (optional)
custom:
  ...
  offline-variables:
    stages:
      - local  # Default
    file: .env # Default
    variables: # Optional
      - ssm:hello-world: my value

By default plugin will first try to locate your variable in .env file (or in the file you specified), and only then under the variables section.

If serverless-offline-variables fails to locate a variable it falls back to original resolver.

Contributions

You are welcome to create pull requests to improve the project. Please check out the contribution quick guide to get started.

License

The project is distributed under MIT license.