Skip to content

Instantly share code, notes, and snippets.

@igorjs
Created February 3, 2020 01:30
Show Gist options
  • Select an option

  • Save igorjs/d0d478f34740937c84d8e37ba5f3d3c4 to your computer and use it in GitHub Desktop.

Select an option

Save igorjs/d0d478f34740937c84d8e37ba5f3d3c4 to your computer and use it in GitHub Desktop.
How to get and AWS SSM parameter using SDK
const AWS = require('aws-sdk');
const ssm = new AWS.SSM();
const getParameterFromSystemManager = async (key, isEncrypted = true) => {
// Fetches a parameter from SSM parameter store.
// Requires a policy for SSM:GetParameter on the parameter being read.
const params = {
Name: key,
WithDecryption: isEncrypted // "true" if is a SecureString, otherwise must be "false"
};
try {
return ssm.getParameter(params).promise();
} catch (err) {
throw new Error('Failed to get parameter from AWS', err.stack);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment