Allows loading ssm parameters via convict
npm i --save ssm-params-convict-adapter
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
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;
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);
}
})();
v0.0.3
WTFPL © Andreas Galazis