Skip to content

Instantly share code, notes, and snippets.

@kellydavid
Created December 11, 2017 02:14
Show Gist options
  • Save kellydavid/1011c170576dafd6cc9433ee8309fef1 to your computer and use it in GitHub Desktop.
Save kellydavid/1011c170576dafd6cc9433ee8309fef1 to your computer and use it in GitHub Desktop.
getting ssm parameter in node lambda
var AWS = require('aws-sdk');
var ssm = new AWS.SSM();
exports.handler = function(event, context) {
// TODO implement
console.log('What is the secret??');
console.log(process.env.secret1);
getParameterFromSystemManager(function(){
console.log('done');
context.done(null, 'Hello from Lambda');
});
};
function getParameterFromSystemManager(callback) {
// Fetches a parameter called REPO_NAME from SSM parameter store.
// Requires a policy for SSM:GetParameter on the parameter being read.
var params = {
Name: 'REPO_NAME',
/* required */
WithDecryption: /*true ||*/ false
};
console.log('in the getParameterFromSystemManager function')
var request = ssm.getParameter(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
callback();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment