Last active
March 17, 2017 16:59
-
-
Save psbolden/50e9eec8e44c56dc9b4fe49b8a5e44bf to your computer and use it in GitHub Desktop.
invoke lambda function from AWS Javascript SDK
This file contains hidden or 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
| //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