Package Exports
- aws-lambda-invoke
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (aws-lambda-invoke) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
aws-lambda-invoke 
Library that makes it easier to invoke lambda functions with promises.
Installation
npm install --save aws-lambda-invokeUsage
Load the library and pass in the AWS library.
var AWS = require('aws-sdk');
var lambda = require('aws-lambda-invoke')(AWS);Why am I not embedding the aws-sdk in the library? This is because in AWS Lambda, the aws-sdk is globally available for you to use. By not
embedding the aws-sdk library, you can keep the footprint of the lambda build smaller.
Sychronous
The invoke method calls the lambda function synchronously. This means that it will wait untill the called lambda function
returns a result or fails.
// Invoke the function
lambda.invoke('MyLambdaFunction', {hello: 'world'})
.then(function(result) {
// Do something with the result of MyLambdaFunction
})Asynchronous
If you don't have to wait for the response of the lambda function you can use the invokeAsync method.
// Invoke the function
lambda.invokeAsync('MyLambdaFunction', {hello: 'world'})
.then(function() {
// The MyLambdaFunction is invoked successfully
});Raw Lambda
If you want to do something with the lambda object created in the aws-lambda-invoke library, you can because the lambda function is stored
in the raw property of the library.
var params = {
FunctionName: 'MyLambdaFunction',
InvocationType: 'RequestResponse',
Payload: JSON.stringify({hello: 'world'})
};
lambda.raw.invoke(params, function(err, result) {
// Handle the result
});API
invoke(name, [payload])
Returns a promise that resolves the payload returned by the invoked lambda function.
invokeAsync(name, [payload])
Returns a promise that resolves nothing.
name
Required
Type: string
The name of the lambda function you want to invoke.
payload
Type: object|string
The payload you want to send to the lambda function you are invoking.
Contributors
- Sam Verschueren [sam.verschueren@gmail.com]
License
MIT © Sam Verschueren