Skip to content

Instantly share code, notes, and snippets.

@shirish87
Created July 9, 2019 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirish87/b43e5df6274531163beb62846f6c7be5 to your computer and use it in GitHub Desktop.
Save shirish87/b43e5df6274531163beb62846f6c7be5 to your computer and use it in GitHub Desktop.
AWS Systems Manager: Parameter Store
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