Class: Lambda

aws-greengrass-core-sdk~Lambda()

Constructs a service interface object. Each API operation is exposed as a function on service.

Constructor

new Lambda()

Constructs a service object. This object has one method for each API operation.
Source:
Example

Constructing a Lambda object

var lambda = new GG.Lambda();

Methods

invoke(params, callback)

Invokes a specific Lambda function.
In Greengrass, version of the Lambda which you would like to invoke needs to be provided.
Parameters:
Name Type Description
params Object
Properties
Name Type Attributes Description
FunctionName String The Lambda function name. You can specify Amazon Resource Name (ARN) of the function (for example, arn:aws:lambda:us-west-2:account-id:function:ThumbNail).
InvocationType String <nullable>
By default, the Invoke API assumes RequestResponse invocation type. You can optionally request asynchronous execution by specifying Event as the InvocationType. Possible values include:
  • "Event"
  • "RequestResponse"
ClientContext String <nullable>
Using the ClientContext you can pass client-specific information to the Lambda function you are invoking. You can then process the client information in your Lambda function as you choose through the context variable. For an example of a ClientContext JSON, see the main page or an example folder for an example.
The ClientContext JSON must be base64-encoded.
Payload Buffer | TypedArray | Blob | String Payload that you want to provide to your Lambda function as input.
Qualifier String <nullable>
You can use this optional parameter to specify a Lambda function version if it was not included in the FunctionName field. If you specify a function version, the API uses the qualified function ARN to invoke a specific Lambda function.
If you don't provide this parameter, then the API uses the FunctionName field only. If it does not have a version number of the target lambda, the call will fail.
callback lambdaCallback The callback.
Source:
Examples

To invoke a Lambda function

//This operation invokes a Lambda function

var params = {
  ClientContext: "MyApp",
  FunctionName: "MyFunction",
  InvocationType: "Event",
  Payload: <json | binary>,
  Qualifier: "1"
};
lambda.invoke(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Calling the invoke operation

var params = {
  FunctionName: 'STRING_VALUE', // required
  ClientContext: 'STRING_VALUE',
  InvocationType: Event | RequestResponse,
  Payload: <json | binary>,
  Qualifier: 'STRING_VALUE'
};
lambda.invoke(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});