You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@adikari/config-store

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adikari/config-store

Read configuration from config stores


Version published
Weekly downloads
5
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Parameter Store Reader

Reads parameters from specified provider

Installation

# Via yarn
$ yarn add @adikari/config-store

# Via npm
$ npm install @adikari/config-store

Examples

SSM Provider

Add IAM policy to allow getting parameters from ssm.

provider:
  name: aws
  iamRoleStatements:
    - Effect: Allow
      Action:
        - ssm:GetParameters # Allow Parameter Store to be read
      Resource:
        - arn:aws:ssm:${env:AWS_REGION}:${env:AWS_ACCOUNT_ID}:parameter/staging/foo-service/*
const { makeConfigStore } = require('@adikari/config-store');
const { STAGE } = process.env;

const configStore = makeConfigStore({
  configPath: `/${SERVICE_STAGE}/foo-service/config`,
  secretPath: `/${SERVICE_STAGE}/foo-service/secret`,
  provider: {
    name: 'ssm'
  }
});

return Promise.all([
  configStore.getConfigs([
    'THE_CONFIG_1',
    'THE_CONFIG_2'
  ]),
  configStore.getSecrets([
    'THE_SECRET_1'
  ])
])
.then(([configs, secrets]) => ({ ...configs, ...secrets }))
.then(console.log);

/* console.log output
{
  THE_CONFIG_1: 'the config 1',
  THE_CONFIG_2: 'the config 2',
  THE_SECRET_1: 'the secret 1'
};
*/

DynamoDB Provider

Add IAM policy to allow getting parameters from dynamodb.

provider:
  name: aws
  iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:Query # Allow Parameter Store to be read
      Resource:
        - arn:aws:dynamodb:${env:AWS_REGION}:${env:AWS_ACCOUNT_ID}:table/config-service*
const { makeConfigStore } = require('@adikari/config-store');
const { STAGE } = process.env;

const configStore = makeConfigStore({
  configPath: `/${SERVICE_STAGE}/foo-service/config`,
  secretPath: `/${SERVICE_STAGE}/foo-service/secret`,
  provider: {
    tableName: `config-service-${SERVICE_STAGE}`
  }
});

return Promise.all([
  configStore.getConfigs([
    'THE_CONFIG_1',
    'THE_CONFIG_2'
  ]),
  configStore.getSecrets([
    'THE_SECRET_1'
  ])
])
.then(([configs, secrets]) => ({ ...configs, ...secrets }))
.then(console.log);

/* console.log output
{
  THE_CONFIG_1: 'the config 1',
  THE_CONFIG_2: 'the config 2',
  THE_SECRET_1: 'the secret 1'
};
*/

Keywords

FAQs

Package last updated on 01 Apr 2022

Did you know?

Socket

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
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc