TestState - Amazon Step Functions
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

TestState

Accepts the definition of a single state and executes it. You can test a state without creating a state machine or updating an existing state machine. Using this API, you can test the following:

You can call this API on only one state at a time. The states that you can test include the following:

The TestState API assumes an IAM role which must contain the required IAM permissions for the resources your state is accessing. For information about the permissions a state might need, see IAM permissions to test a state.

The TestState API can run for up to five minutes. If the execution of a state exceeds this duration, it fails with the States.Timeout error.

TestState doesn't support Activity tasks, .sync or .waitForTaskToken service integration patterns, Parallel, or Map states.

Request Syntax

{ "definition": "string", "input": "string", "inspectionLevel": "string", "revealSecrets": boolean, "roleArn": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

definition

The Amazon States Language (ASL) definition of the state.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1048576.

Required: Yes

input

A string that contains the JSON input data for the state.

Type: String

Length Constraints: Maximum length of 262144.

Required: No

inspectionLevel

Determines the values to return when a state is tested. You can specify one of the following types:

  • INFO: Shows the final state output. By default, Step Functions sets inspectionLevel to INFO if you don't specify a level.

  • DEBUG: Shows the final state output along with the input and output data processing result.

  • TRACE: Shows the HTTP request and response for an HTTP Task. This level also shows the final state output along with the input and output data processing result.

Each of these levels also provide information about the status of the state execution and the next state to transition to.

Type: String

Valid Values: INFO | DEBUG | TRACE

Required: No

revealSecrets

Specifies whether or not to include secret information in the test result. For HTTP Tasks, a secret includes the data that an EventBridge connection adds to modify the HTTP request headers, query parameters, and body. Step Functions doesn't omit any information included in the state definition or the HTTP response.

If you set revealSecrets to true, you must make sure that the IAM user that calls the TestState API has permission for the states:RevealSecrets action. For an example of IAM policy that sets the states:RevealSecrets permission, see IAM permissions to test a state. Without this permission, Step Functions throws an access denied error.

By default, revealSecrets is set to false.

Type: Boolean

Required: No

roleArn

The Amazon Resource Name (ARN) of the execution role with the required IAM permissions for the state.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Required: Yes

Response Syntax

{ "cause": "string", "error": "string", "inspectionData": { "afterInputPath": "string", "afterParameters": "string", "afterResultPath": "string", "afterResultSelector": "string", "input": "string", "request": { "body": "string", "headers": "string", "method": "string", "protocol": "string", "url": "string" }, "response": { "body": "string", "headers": "string", "protocol": "string", "statusCode": "string", "statusMessage": "string" }, "result": "string" }, "nextState": "string", "output": "string", "status": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

cause

A detailed explanation of the cause for the error when the execution of a state fails.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 32768.

error

The error returned when the execution of a state fails.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 256.

inspectionData

Returns additional details about the state's execution, including its input and output data processing flow, and HTTP request and response information. The inspectionLevel request parameter specifies which details are returned.

Type: InspectionData object

nextState

The name of the next state to transition to. If you haven't defined a next state in your definition or if the execution of the state fails, this field doesn't contain a value.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 80.

output

The JSON output data of the state. Length constraints apply to the payload size, and are expressed as bytes in UTF-8 encoding.

Type: String

Length Constraints: Maximum length of 262144.

status

The execution status of the state.

Type: String

Valid Values: SUCCEEDED | FAILED | RETRIABLE | CAUGHT_ERROR

Errors

For information about the errors that are common to all actions, see Common Errors.

InvalidArn

The provided Amazon Resource Name (ARN) is not valid.

HTTP Status Code: 400

InvalidDefinition

The provided Amazon States Language definition is not valid.

HTTP Status Code: 400

InvalidExecutionInput

The provided JSON input data is not valid.

HTTP Status Code: 400

ValidationException

The input does not satisfy the constraints specified by an Amazon service.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: