Socket
Socket
Sign inDemoInstall

@adikari/config-store

Package Overview
Dependencies
6
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adikari/config-store


Version published
Weekly downloads
1
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

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc