Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

This plugin is used to resolve AWS resources in the debugger environment variables when using the serverless framework.

License

Notifications You must be signed in to change notification settings

mutual-of-enumclaw/serverless-plugin-local-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serverless-plugin-local-env

This plugin is used to resolve AWS resources in the debugger environment variables when using the serverless framework.

Use case

When debugging with serverless framework, resources created and referenced as part of the framework will often resolve to "[object object]". This makes debugging with serverless framework very difficult as reproducing the lambda environment must then be done with command line attributes.

This plugin will connect with your AWS Stack and its resources in order to resolve "Ref", "Fn::GetAtt" and "Fn::ImportValue" statements when setting up your environment variables for local debugging.

Implementing

Install the plugin into the directory your serverless.yml is located

npm install @moe-tech/serverless-plugin-local-env

Add the plugin to your serverless yaml plugins

plugins:
    - "@moe-tech/serverless-plugin-local-env"

Invoke your function

serverless invoke local --function {Function Name}

Cache

In order to improve performance this plugin creates a cache of resources references. This cache is automatically cleared out when a new deployment occurs, but can also be manually cleared by deleting the ".serverless/invoke.cache.json" file.

Example

The example provided is a serverless project which contains a DynamoDB Table, an SNS Topic, an SQS Queue, a Lambda Function and it exports a value.

Steps:

  1. navigate to the example directory in the console "./example"
  2. install dependencies
    npm ci
  3. deploy the serverless project
    serverless deploy
  4. Un-comment lines #21 & #22 in the serverless.yml file
  5. Invoke the function to run locally
    serverless invoke local --function hello
    or
    npm start
  6. View the console logs which are printed

About

This plugin is used to resolve AWS resources in the debugger environment variables when using the serverless framework.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •