AWS Lambda Node

The AWS: Lambda Node allows a workflow to run an AWS Lambda function and optionally store the returned value from the function in the payload.

AWS Lambda Node

Node Properties

There are four sections of node properties for the AWS Lambda node: AWS Config, Lambda Config, Output, and Error.

AWS Configuration

AWS Lambda Node Credentials

There are two options for configuring credentials:

  • Choose a Service Credential: Retrieves your AWS credentials from the selected service credential.

    • Credential Name Template: Choose which of your application’s AWS service credentials you would like to use. Note: Service credentials are not accessible from Edge Workflows, so only direct configuration is available for them.
  • Enter Connection Info: Configure the AWS credentials directly within the node. All fields are required.

    • AWS Region Template: The AWS region to connect to.
    • AWS Access Key ID Template: The AWS access key ID associated with the AWS account you wish to use. This field is templatable.
    • AWS Secret Access Key Template: The AWS secret access key associated with the AWS account you wish to use. This field is templatable.

We recommend that you create an AWS Key/Secret pair specifically for use for our workflow nodes - one that only has access to your AWS Lambda functions. We also recommend that you store these values as service credentials.

Lambda Configuration

AWS Lambda Node Config

Next, define the function to execute and the data to provide as its argument …

  • Lambda Function Name: The name of the function to execute. This must match the name of a function that’s available to the credentials provided above. The function name accepts string templates.
  • Data Method: The data to provide to the function. Options are …

    • Workflow Payload: When selected, the entire current workflow payload is sent as the data to the Lambda call.
    • Payload Path: When selected, you must provide a payload path, and the value at that path on the current payload is sent as the data to the Lambda call.
    • JSON Template: When selected, you must provide a JSON template, and the result of that template is sent as the data to the Lambda call.
  • Timeout Template: The length of time, in milliseconds, to wait before timing out the execution. For Edge Workflows, this defaults to the value of the MAX_EXTERNAL_CALL_TIME environment variable, and the Timeout Template option can only be set on the Lambda Node in GEA version 1.47.0 or higher. For all other workflows, this defaults to 30000 (30 seconds).

In the example above, Workflow Payload is selected, so the entire current payload will be handed to the myLambdaFunctionName call.

Output Configuration

AWS Lambda Node Output

If the Lambda function that is being called returns a result, it can optionally be stored for later use in the workflow. In the example above, the result will be stored at the payload path data.phoneNumber on the current payload.

Error Configuration

This section determines how errors are handled when the node is run. There are two options:

  • Error the workflow: Halt the workflow at this node, preventing further execution.
  • Store AWS Lambda error at payload path: Configure a payload path at which to store the error.

Note: For edge workflows, this option is only available on edge version 1.18.1 or higher. On older versions, the workflow will always halt on errors.

Node Example

Here is an example payload after the above AWS Lambda Node has been run and received information back from the useNumberLookup function:

{
  "time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST),
  "data": {
    "current": 10,
    "on": true,
    "phoneNumber": {
      "LogResult": "AWS_LOGGING_INFO_WOULD_BE_HERE",
      "Payload": { "phoneNumber": "212 867-5309" },
      "StatusCode": 200,
    }
  },
  "globals": {
    "awsKey": "AWS_KEY_WOULD_BE_HERE",
    "awsSecret": "AWS_SECRET_WOULD_BE_HERE"
  },
  "applicationId": "568beedeb436ab01007be53d",
  "applicationName": "Embree",
  "triggerId": "56c8967bb8df0f0100d629120",
  "triggerType": "deviceId",
  "deviceTags": {
    "floor": ["2"],
    "location": ["warehouse1"]
  },
  "deviceName": "My Factory Device",
  "flowId": "56c74add04d0b50100043381",
  "flowName": "Power Usage Alert"
}

Node Errors

In the case that the AWS Lambda function fails, there are two possible options. You can either error the workflow, or you can store the error at a path on the payload.

Below is an example of an error stored on the payload when the configured AWS credentials are invalid and the error is stored on the payload path “working.lambdaError”:

{
  "working": {
    "lambdaError": {
      "message": "The security token included in the request is invalid.",
      "type": "AWSLambda"
    },
    ...
  }
}

Was this page helpful?


Still looking for help? You can also search the WEGnology Forums or submit your question there.