Tutorials
Last updated
Was this helpful?
Last updated
Was this helpful?
Note
In Step Functions, a workflow is called a state machine, which is a series of event-driven steps. Each step in a workflow is called a state. A Task
state represents a unit of work that another AWS service, such as AWS Lambda, performs. A Task
state can call any AWS service or API. For more information, see:
Important Ensure that your Lambda function is under the same AWS account and AWS Region as your state machine.
Note
You can also pass payloads while invoking Lambda from a state machine. For more information and examples about invoking Lambda by passing payload in the Parameters
field, see .
Note
You can also create state machines that Retry
on timeouts or those that use Catch
to transition to a specific state when an error or timeout occurs. For examples of these error handling techniques, see .
Important Ensure that your Lambda function is under the same AWS account and AWS Region as your state machine.
Note You must configure EventBridge rule in the same AWS Region as the Amazon S3 bucket.
Note
Although Amazon API Gateway can start a Step Functions execution by calling [StartExecution](https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartExecution.html)
, you must call [DescribeExecution](https://docs.aws.amazon.com/step-functions/latest/apireference/API_DescribeExecution.html)
to get the result.
Note
For more information, see the StartExecution
in the AWS Step Functions API Reference.
If you don't want to include the ARN of your state machine in the body of your API Gateway call, you can configure a body-mapping template, as shown in the following example.
Note You can view the execution by choosing your state machine on the .
Important Ensure that your activity task is under the same AWS account as your state machine.
Note
If you set index
to 9
for this test, the index
increments to 10
, and continue
is false
.
Note
If you set index
to 9
for this test, the index
increments to 10
, and continue
is false
.
Note Save the Amazon Resource Name (ARN) of this state machine.
Note
You can update the "Resource": "*"
line in the previous example to reference the ARN of your ContinueAsNew
state machine. This restricts the policy so that it can only start an execution of that specific state machine.
Note You will need to provide a valid email address that you have access to when you create the AWS CloudFormation stack.
Important Ensure that your Lambda function is under the same AWS account and AWS Region as your state machine.
Note For a more complete example of an activity worker, see . This example provides an implementation based on best practices, which you can use as a reference for your activity worker. The code implements a consumer-producer pattern with a configurable number of threads for pollers and activity workers.
Note
The EnvironmentVariableCredentialsProvider
class in this example assumes that the AWS_ACCESS_KEY_ID
(or AWS_ACCESS_KEY
) and AWS_SECRET_KEY
(or AWS_SECRET_ACCESS_KEY
) environment variables are set. For more information about providing the required credentials to the factory, see in the AWS SDK for Java API Reference and in the AWS SDK for Java Developer Guide.
By default the AWS SDK will wait up to 50 seconds to receive data from the server for any operation. The GetActivityTask
operation is a long-poll operation that will wait up to 60 seconds for the next available task. To prevent receiving a SocketTimeoutException
error, set SocketTimeout to 70 seconds.
Note If you have completed the tutorial, you can skip this step and use that Lambda function.
Note
Under the Task state options section, you can also configure Retry
, Catch
, and TimeoutSeconds
options. See .