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

In this section the Lambda Function and Data Method are selected. The function to call can take a string template, so the value can be pulled off the payload - but in the example above, the function is hard-coded to userNumberLookup.

There are three options for Data Method:

  • Workflow Payload: with this option, the entire current workflow payload is sent as the data to the lambda call.
  • Payload Path: with this option, 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: with this option, you must provide a JSON template, and the result of that template is sent as the data to the lambda call.

In the example above, Workflow Payload is selected, so the entire current payload will be handed to the userNumberLookup 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 Losant Forums or submit your question there.