A quick app configurator that loads AWS KMS secrets via Setec.
Options:
config
: your configuration object, with any Setec secrets as{secret: 'secret-name'}
; required unlessconfigFile
is givenconfigFile
: a JSON file version ofconfig
, or a Javscript file exporting the same; overridesconfig
; required unlesconfig
is givens3Bucket
: the S3 bucket from which Setec should load secret configuration; requireds3Prefix
: the prefix for Setec to use when loading secret configuration; defaults to'setec'
Asynchronously load Setec secrets and return the resolved configuration object via a Promise.
Returns Promise(configWithSecretsLoaded)
Returns an object suitable for exporting as a Node.js module for the following convenient usage pattern:
const SetecAppConfig = require('setec-app-config');
module.exports = new SetecAppConfig({
configFile: 'path/to/my-secret-free-config.json',
s3Bucket: 'my-setec-config-bucket'
}).exportable();
const myConfig = require('./my-config-module');
// ES7 example
await myConfig.load();
db.connect(myConfig.user, myConfig.secretPassword); // i.e., do something with loaded secrets
// pre-ES7 example
myConfig.load().then(() => {
db.connect(myConfig.user, myConfig.secretPassword); // i.e., do something with loaded secrets
});