Socket
Socket
Sign inDemoInstall

@sp-tools/kloud-parameter

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sp-tools/kloud-parameter

Read configuration from parameter store


Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Parameter Store Reader

Reads parameters from specified provider

Examples

SSM Provider

In serverless.yml

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 { makeParameterStore } = require('@sp-tools/kloud-parameter');
const { STAGE } = process.env;

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

return Promise.all([parameterStore.getConfigs(['THE_CONFIG_1', 'THE_CONFIG_2']), parameterStore.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

In serverless.yml

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/kloud-config-some-service*
const { makeParameterStore } = require('@sp-tools/kloud-parameter');
const { STAGE } = process.env;

const parameterStore = makeParameterStore({
  configPath: `/${SERVICE_STAGE}/foo-service/config`,
  secretPath: `/${SERVICE_STAGE}/foo-service/secret`,
  provider: {
    tableName: `kloud-config-some-service-${SERVICE_STAGE}`
  }
});

return Promise.all([parameterStore.getConfigs(['THE_CONFIG_1', 'THE_CONFIG_2']), parameterStore.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'
};
*/

FAQs

Package last updated on 15 Aug 2020

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc