This library is written for loading environment variables on AWS lambda from credstash secrets store.
npm install [--save-dev] lambda-credstash-envvars
Process environment variables are cached for warm lambda containers, and are only loaded from DyanmoDB (credstash) for cold containers.
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 to1
to enable env vars loading process`CREDSTASH_TABLE
- name of DynamoDB table used for storing secrets by credstashCREDSTASH_REGION
- region of DynamoDB table where credstash secrets are storeCREDSTASH_VARIABLES_FORCE_LOAD
- if set to1
variables will not be cached, and will be always loaded regardless if running in hot or cold containers.CREDSTASH_FAIL_ON_ERROR
- if set to1
will make the root process exit on failure to read or decrypt environment variables stored in credstash.