Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.