Skip to content

casamagalhaes/secrets-manager-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Secrets Manager Loader

Retrieves, parses and loads secrets from AWS Secrets Manager directly to process.env

Example

If your secret prod/myawesomesecret/module value is

{
  "USERNAME": "johndoe",
  "PASSWORD": "hunter2"
}

Then this code

(async () => {
    await require('secrets-manager-loader').load({
        secretId: 'prod/myawesomesecret/module'
    });
    console.log(process.env);
})();

Would generate this output

{
  //... whatever is in your environment
  USERNAME: 'johndoe',
  PASSWORD: 'hunter2'
}

Requirements

The role or user running the load function must have a policy allowing secretsmanager:GetSecretValue to the specified secret in secretId

Warning

AWS Secrets Manager is not free (https://aws.amazon.com/secrets-manager/pricing/), each call to load means an API call, so don't overdo it. You should think of a caching strategy to avoid any problems on frequent workloads.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published