Skip to content

Instantly share code, notes, and snippets.

@TimothyJones
Created August 28, 2019 04:44
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TimothyJones/8d71a52665bca3196a6c19488efbc2c4 to your computer and use it in GitHub Desktop.
Save TimothyJones/8d71a52665bca3196a6c19488efbc2c4 to your computer and use it in GitHub Desktop.
Example showing a promisified SSM config reader for SecureString parameters
const AWS = require('aws-sdk');
const ssm = new AWS.SSM();
const configFeatures = {
'/path/to/your/config/option': 'someOption',
'/path/to/your/config/something_else': 'somethingElse'
};
const getConfig = () =>
new Promise((resolve, reject) => {
ssm.getParameters(
{
Names: Object.keys(configFeatures),
WithDecryption: true
},
(err, data) => {
if (err) {
console.log(err, err.stack);
reject(err);
} else {
const config = data.Parameters.reduce(
(cfg, i) => ({
...cfg,
[configFeatures[i.Name]]: i.Value
}),
{}
);
resolve(config);
}
}
);
});
module.exports = getConfig;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment