Created
August 19, 2019 12:42
-
-
Save takahirohonda/f9ca46f2ab4a724d6f5ed4e1fdb8e8fd to your computer and use it in GitHub Desktop.
node-module-to-retrieve-multiple-parameters-from-aws-parameter-store-4.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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