0.1.0 • Published 5 years ago

serverless-local-importvalue v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

NPM

Serverless Local ImportValue

When using serverless invoke local, environment variables that use AWS CloudFormation's !ImportValue will show up as [object Object]. This plugin is meant to fix that.

Installation

npm i serverless-local-importvalue --save-dev

yarn add serverless-local-importvalue --dev

Usage

Simply include this in your serverless.yml's plugins section and invoke your function using npx serverless invoke local

Example

command:

npx serverless invoke local -f hello

serverless.yml:

plugins:
    - serverless-local-importvalue

provider:
    # ...
    environment:
        SOME_RESOURCE: !ImportValue some-resource-from-some-stack
functions:
    hello:
        handler: src/hello.handler

hello.js:

exports.handler = (event) => {
    console.log(process.env.SOME_RESOURCE);
    return 'hello world';
}