Skip to content

toshke/lambda-credstash-vars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Lambda CredsStash environment variables

Introduction

This library is written for loading environment variables on AWS lambda from credstash secrets store.

Installation

npm install [--save-dev] lambda-credstash-envvars

Caching

Process environment variables are cached for warm lambda containers, and are only loaded from DyanmoDB (credstash) for cold containers.

Usage

Just call imported function and pass callback as code to execute once variables are loaded.

const envvars = require('lambda-credstash-envvars');

exports.table = (event, context, cb) => {
    envvars(()=>{
      console.log(JSON.stringify(process.env),null,2);
      execute_business_logic();
    });
};

Behavior is controlled via Lambda's process environment variables:

  • CREDSTASH_VARIABLES_LOAD set this to 1 to enable env vars loading process`
  • CREDSTASH_TABLE - name of DynamoDB table used for storing secrets by credstash
  • CREDSTASH_REGION - region of DynamoDB table where credstash secrets are store
  • CREDSTASH_VARIABLES_FORCE_LOAD - if set to 1 variables will not be cached, and will be always loaded regardless if running in hot or cold containers.
  • CREDSTASH_FAIL_ON_ERROR - if set to 1 will make the root process exit on failure to read or decrypt environment variables stored in credstash.

About

Load environment variables in Amazon lambda functions from credstash

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published