Created
December 11, 2017 02:14
-
-
Save kellydavid/1011c170576dafd6cc9433ee8309fef1 to your computer and use it in GitHub Desktop.
getting ssm parameter in node lambda
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
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