Skip to content

Instantly share code, notes, and snippets.

@psbolden
Last active March 17, 2017 16:59
Show Gist options
  • Select an option

  • Save psbolden/50e9eec8e44c56dc9b4fe49b8a5e44bf to your computer and use it in GitHub Desktop.

Select an option

Save psbolden/50e9eec8e44c56dc9b4fe49b8a5e44bf to your computer and use it in GitHub Desktop.
invoke lambda function from AWS Javascript SDK
//Source: http://stackoverflow.com/questions/33659059/invoke-amazon-lambda-function-from-node-app?rq=1
var AWS = require('aws-sdk');
// you shouldn't hardcode your keys in production! See http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html
AWS.config.update({accessKeyId: 'akid', secretAccessKey: 'secret'});
var lambda = new AWS.Lambda();
var params = {
FunctionName: 'myImageProcessingLambdaFn', /* required */
Payload: PAYLOAD_AS_A_STRING
};
lambda.invoke(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment