Created
July 9, 2019 08:58
-
-
Save shirish87/b43e5df6274531163beb62846f6c7be5 to your computer and use it in GitHub Desktop.
AWS Systems Manager: Parameter Store
This file contains 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
import * as AWS from 'aws-sdk'; | |
async function getParameterStoreValues(names: string[], region: string) { | |
const ssm = new AWS.SSM({ region }); | |
const { Parameters = [], InvalidParameters = [] } = await ssm.getParameters({ Names: names }).promise(); | |
if (InvalidParameters.length) { | |
throw new Error(`Invalid parameter names: ${InvalidParameters.join(', ')}`); | |
} | |
return names.map(name => Parameters.find(p => p.Name === name).Value); | |
} | |
// Usage | |
// const [ value1, value2 ] = await getParameterStoreValues(['key1', 'key2'], 'us-west-2'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment