Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save takahirohonda/f9ca46f2ab4a724d6f5ed4e1fdb8e8fd to your computer and use it in GitHub Desktop.
Save takahirohonda/f9ca46f2ab4a724d6f5ed4e1fdb8e8fd to your computer and use it in GitHub Desktop.
node-module-to-retrieve-multiple-parameters-from-aws-parameter-store-4.js
'use strict';
const AWS = require('aws-sdk');
const { getParameter } = require('../play/get-parameter');
let ssm;
const getParameters = (parameterNames, region, getParameterFunc=getParameter) => {
if (!ssm) {
ssm = new AWS.SSM({apiVersion: '2014-11-06', region: region});
}
return Promise.all(parameterNames
.map(parameterName => getParameterFunc(parameterName, ssm)))
.then(values => parameterNames
.reduce((obj, paramName, index) => ({ ...obj, [paramName]: values[index]}), {}))
.catch(err => err);
};
module.exports = { getParameters };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment