ssm-params-convict-adapter
v0.0.12
Published
Allows loading ssm parameters via convict
Downloads
9
Readme
ssm-params-convict-adapter
Allows loading ssm parameters via convict
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
Licence
WTFPL © Andreas Galazis