StepFunctions client

This page contains examples with the StepFunctions client. See the client introduction for a more detailed description how to use a client. You may also want to consider the authentication documentation to understand the many ways you can authenticate with AWS.

The StepFunctions package could be installed with Composer.

composer require async-aws/step-functions

A new client object may be instantiated by:

use AsyncAws\StepFunctions\StepFunctionsClient; $stepFunctions = new StepFunctionsClient();

The authentication parameters is read from the environment by default. You can also specify a AWS access id and secret:

use AsyncAws\StepFunctions\StepFunctionsClient; $stepFunctions = new StepFunctionsClient([ 'accessKeyId' => 'my_access_key', 'accessKeySecret' => 'my_access_secret', 'region' => 'eu-central-1', ]);

For all available options, see the configuration reference.

Usage

Start a state machine execution

use AsyncAws\StepFunctions\Input\StartExecutionInput; use AsyncAws\StepFunctions\StepFunctionsClient; $stepFunctions = new StepFunctionsClient(); $result = $stepFunctions->startExecution(new StartExecutionInput([ 'stateMachineArn' => 'arn:sfn', 'input' => '{"foo": "bar"}', ])); echo $result->getExecutionArn();

Send a task heartbeat

use AsyncAws\StepFunctions\Input\SendTaskHeartbeatInput; use AsyncAws\StepFunctions\StepFunctionsClient; $stepFunctions = new StepFunctionsClient(); $result = $stepFunctions->sendTaskHeartbeat(new SendTaskHeartbeatInput([ 'taskToken' => 'qwertyuiop', ]));

Mark as task as successful

use AsyncAws\StepFunctions\Input\SendTaskSuccessInput; use AsyncAws\StepFunctions\StepFunctionsClient; $stepFunctions = new StepFunctionsClient(); $result = $stepFunctions->sendTaskSuccess(new SendTaskSuccessInput([ 'taskToken' => 'qwertyuiop', 'output' => '{"success": ":partyparrot:"}', ]));

Mark as task as failed

use AsyncAws\StepFunctions\Input\SendTaskFailureInput; use AsyncAws\StepFunctions\StepFunctionsClient; $stepFunctions = new StepFunctionsClient(); $result = $stepFunctions->sendTaskSuccess(new SendTaskFailureInput([ 'taskToken' => 'qwertyuiop', 'error' => 'err_foo', 'cause' => 'Crash!', ]));

The source code to this page is found on GitHub.