AWS Step Functions
Developer Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Invoke Lambda with Step Functions

Step Functions can control certain AWS services directly from the Amazon States Language. For more information, see:

For more information about managing state input, output and results, see Input and Output Processing in Step Functions.

Supported APIs:

The following includes a Task state that invokes a Lambda function.

{ "StartAt":"CallLambda", "States":{ "CallLambda":{ "Type":"Task", "Resource":"arn:aws:states:::lambda:invoke", "Parameters":{ "FunctionName":"MyFunction" }, "End":true } } }

The following includes a Task state that implements the callback service integration pattern.

{ "StartAt":"GetManualReview", "States":{ "GetManualReview":{ "Type":"Task", "Resource":"arn:aws:states:::lambda:invoke.waitForTaskToken", "Parameters":{ "FunctionName":"get-model-review-decision", "Payload":{ "model.$":"$.new_model", "token.$":"$$.Task.Token" }, "Qualifier":"prod-v1" }, "End":true } } }


The Lambda invoke API includes logs in the response by default. Multiple Lambda invocations in a workflow can trigger States.DataLimitExceeded errors. To avoid this, include "LogType" = "None" as a parameter when you invoke your Lambda functions.

To simply invoke a Lambda function, you can also call the resource ARN directly in the "Resource" string.

{ "StartAt":"CallFunction", "States":{ "CallFunction": { "Type":"Task", "Resource":"arn:aws:lambda:us-east-1:123456789012:function:HelloFunction", "End": true } } }

When you invoke Lambda using an ARN directly from the "Resource" field, you cannot specify .waitForTaskToken, and the state input is passed to Lambda as the payload. The output of the Lambda function is the result. To have a Lambda task wait for a task token, see the previous callback pattern example.

You can invoke a specific Lambda function version or alias by specifying those options in the Amazon Resource Name in the Resource field. See the following in the Lambda documentation.

For information on how to configure IAM when using Step Functions with other AWS services, see IAM Policies for Integrated Services.