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:
-
A state's input and output processing data flow
-
An AWS service integration request and response
-
An HTTP Task request and response
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 only supports the following when a mock is specified: Activity tasks, .sync or .waitForTaskToken
service integration patterns, Parallel, or Map states.
Request Syntax
{
"context": "string",
"definition": "string",
"input": "string",
"inspectionLevel": "string",
"mock": {
"errorOutput": {
"cause": "string",
"error": "string"
},
"fieldValidationMode": "string",
"result": "string"
},
"revealSecrets": boolean,
"roleArn": "string",
"stateConfiguration": {
"errorCausedByState": "string",
"mapItemReaderData": "string",
"mapIterationFailureCount": number,
"retrierRetryCount": number
},
"stateName": "string",
"variables": "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.
- context
-
A JSON string representing a valid Context object for the state under test. This field may only be specified if a mock is specified in the same request.
Type: String
Length Constraints: Maximum length of 262144.
Required: No
- definition
-
The Amazon States Language (ASL) definition of the state or state machine.
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 setsinspectionLeveltoINFOif 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 | TRACERequired: No
-
- mock
-
Defines a mocked result or error for the state under test.
A mock can only be specified for Task, Map, or Parallel states. If it is specified for another state type, an exception will be thrown.
Type: MockInput object
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
revealSecretstotrue, you must make sure that the IAM user that calls theTestStateAPI has permission for thestates:RevealSecretsaction. For an example of IAM policy that sets thestates:RevealSecretspermission, see IAM permissions to test a state. Without this permission, Step Functions throws an access denied error.By default,
revealSecretsis set tofalse.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: No
- stateConfiguration
-
Contains configurations for the state under test.
Type: TestStateConfiguration object
Required: No
- stateName
-
Denotes the particular state within a state machine definition to be tested. If this field is specified, the
definitionmust contain a fully-formed state machine definition.Type: String
Length Constraints: Minimum length of 1. Maximum length of 80.
Required: No
- variables
-
JSON object literal that sets variables used in the state under test. Object keys are the variable names and values are the variable values.
Type: String
Length Constraints: Maximum length of 262144.
Required: No
Response Syntax
{
"cause": "string",
"error": "string",
"inspectionData": {
"afterArguments": "string",
"afterInputPath": "string",
"afterItemBatcher": "string",
"afterItemSelector": "string",
"afterItemsPath": "string",
"afterItemsPointer": "string",
"afterParameters": "string",
"afterResultPath": "string",
"afterResultSelector": "string",
"errorDetails": {
"catchIndex": number,
"retryBackoffIntervalSeconds": number,
"retryIndex": number
},
"input": "string",
"maxConcurrency": number,
"request": {
"