Socket
Socket
Sign inDemoInstall

aws-parameter-store-env

Package Overview
Dependencies
37
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    aws-parameter-store-env

Loads environment variables from AWS Parameter Store


Version published
Weekly downloads
1.4K
increased by2.16%
Maintainers
1
Install size
23.7 kB
Created
Weekly downloads
 

Readme

Source

aws-parameter-store-env

aws-parameter-store-env is a module that loads environment variables from AWS Parameter Store into process.env.

Install

# with npm
npm install aws-sdk aws-parameter-store-env

# with yarn
yarn add aws-sdk aws-parameter-store-env

Usage

Assuming the following parameters are defined in the AWS Parameter Store:

  • app/production/DB_HOST
  • app/production/DB_USER
  • app/production/DB_PASS

The following config can be used to pull those parameters into process.env.

require("aws-parameter-store-env")
  .config({
    path: "app/production/",
    parameters: [
      {
        name: "DB_HOST"
      },
      {
        name: "DB_USER",
        envName: "DB_USERNAME"
      },
      {
        name: "DB_PASS",
        envName: "DB_PASSWORD"
      }
    ],
    region: "us-east-1"
  })
  .then(() => {
    const { DB_HOST, DB_USERNAME, DB_PASSWORD } = process.env;
    // code to run after the environment has been configured
  });

Config

Options

parameters

This value is an array of Parameter objects that define which parameters should be retrieved from the AWS Parameter Store and how those parameters should be named when saved to process.env.

Here is an example Parameter object

{
  name: "app/production/secret",
  envName: "APP_SECRET"
}

The name attribute of the Parameter object is the name of the attribute to be retrieved from the AWS Parameter Store.

The envname attribute of the Parameter object is the name that should be used when applying the parameter value process.env. If this attribute isn't defined the name attribute will be used.

require("aws-parameter-store-env")
  .config({
    parameters: [
      {
        name: "app/production/DB_HOST",
        envName: "DB_HOST"
      },
      {
        name: "app/production/DB_USER",
        envName: "DB_USER"
      },
      {
        name: "app/production/DB_PASS",
        envName: "DB_PASS"
      }
    ],
    region: "us-east-1"
  })
  .then(() => {
    const { DB_HOST, DB_USER, DB_PASS } = process.env;
    // code to run after the environment has been configured
  });
path

The path attribute can be used to reduce redundancy in Parameter names.

require("aws-parameter-store-env")
  .config({
    path: "app/production/"
    parameters: [
      {
        name: "DB_HOST",
      },
      {
        name: "DB_USER",
      },
      {
        name: "DB_PASS",
      }
    ],
    region: "us-east-1"
  })
  .then(() => {
    const { DB_HOST, DB_USER, DB_PASS } = process.env;
    // code to run after the environment has been configured
  });
region

This value is passed to aws-sdk when the SSM service is created. This is the AWS region to pull parameters from.

withDecryption

Default: true

This value is passed passed to aws-sdk. It's then used to decide if secure string values should be decrypted by the SDK. See the AWS documentation for more information.

require("aws-parameter-store-env")
  .config({
    parameters: [
      {
        name: "parameter/store/var/that/you/dont/want/decrypted",
        envName: "ENCRYPTED_VAR"
      }
    ],
    region: "us-east-1",
    withDecryption: false
  })
  .then(() => {
    const { ENCRYPTED_VAR } = process.env;
    // code to run after the environment has been configured
  });
Callback

If you prefer callbacks over promises a callback can be passed as a second parameter to config.

require("aws-parameter-store-env").config(
  {
    path: "app/production/",
    parameters: [
      {
        name: "DB_HOST"
      },
      {
        name: "DB_USER",
        envName: "DB_USERNAME"
      },
      {
        name: "DB_PASS",
        envName: "DB_PASSWORD"
      }
    ],
    region: "us-east-1"
  },
  () => {
    const { DB_HOST, DB_USERNAME, DB_PASSWORD } = process.env;
    // code to run after the environment has been configured
  }
);

Keywords

FAQs

Last updated on 10 Aug 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc