Skip to content

agalazis/ssm-params-convict-adapter

Repository files navigation

TypeScript Maintainability bithound styled with prettier Built with generator-ts-np

ssm-params-convict-adapter

Allows loading ssm parameters via convict

npm npm node version Dependency Security Status Peer Dependencies Security Status Travis PRs Welcome License

Install

npm i --save ssm-params-convict-adapter

Peer Dependencies

Before installing this package you need the following peer dependencies installed in your project (If they are not already installed):

npm i -D aws-sdk convict

How it works?

The schema is expressed as a conventional convict schema with an extra property ssmParameter that eaccepts an object with two values the path and whether it should be strict when requesting the value (error in absence of a value).

Example schema:

const schema = {
  auth: {
    default: true,
    doc: 'Whether authentication is required',
    env: 'TESTDB_AUTH',
    format: Boolean,
  },
  password: {
    default: '',
    doc: 'The example testdb password',
    env: 'TESTDB_PASS',
    format: String,
    ssmParameter: {
      path: '/testdb/db/password',
      strict: false,
    },
  },
  username: {
    default: '',
    doc: 'The example testdb username',
    env: 'TESTDB_USER',
    format: String,
    ssmParameter: {
      path: '/testdb/db/username',
      strict: true,
    },
  },
};
export default schema;

Usage

Example usage:

import * as logger from 'winston';
import SSMParamsConvictAdapter from 'ssm-params-convict-adapter';
import schema from './schema';

(async () => {
  try {
    const config = await SSMParamsConvictAdapter.convict(schema);
    logger.info(JSON.stringify(config.getProperties()));
  } catch (e) {
    logger.log('error', e);
  }
})();

Change log

v0.0.3

used version of ts-np generator

Licence

WTFPL © Andreas Galazis

About

Allows loading ssm parameters via convict

Resources

License

Stars

Watchers

Forks

Packages

No packages published