SFN / Client / test_state
test_state#
- SFN.Client.test_state(**kwargs)#
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 Amazon Web Services 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 theStates.Timeout
error.TestState
doesn’t support Activity tasks,.sync
or.waitForTaskToken
service integration patterns, Parallel, or Map states.See also: AWS API Documentation
Request Syntax
response = client.test_state( definition='string', roleArn='string', input='string', inspectionLevel='INFO'|'DEBUG'|'TRACE', revealSecrets=True|False )
- Parameters:
definition (string) –
[REQUIRED]
The Amazon States Language (ASL) definition of the state.
roleArn (string) –
[REQUIRED]
The Amazon Resource Name (ARN) of the execution role with the required IAM permissions for the state.
input (string) – A string that contains the JSON input data for the state.
inspectionLevel (string) –
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 setsinspectionLevel
toINFO
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.
revealSecrets (boolean) –
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
totrue
, you must make sure that the IAM user that calls theTestState
API has permission for thestates:RevealSecrets
action. For an example of IAM policy that sets thestates:RevealSecrets
permission, see IAM permissions to test a state. Without this permission, Step Functions throws an access denied error.By default,
revealSecrets
is set tofalse
.
- Return type:
dict
- Returns:
Response Syntax
{ 'output': 'string', 'error': 'string', 'cause': 'string', 'inspectionData': { 'input': 'string', 'afterInputPath': 'string', 'afterParameters': 'string', 'result': 'string', 'afterResultSelector': 'string', 'afterResultPath': 'string', 'request': { 'protocol': 'string', 'method': 'string', 'url': 'string', 'headers': 'string', 'body': 'string' }, 'response': { 'protocol': 'string', 'statusCode': 'string', 'statusMessage': 'string', 'headers': 'string', 'body': 'string' } }, 'nextState': 'string', 'status': 'SUCCEEDED'|'FAILED'|'RETRIABLE'|'CAUGHT_ERROR' }
Response Structure
(dict) –
output (string) –
The JSON output data of the state. Length constraints apply to the payload size, and are expressed as bytes in UTF-8 encoding.
error (string) –
The error returned when the execution of a state fails.
cause (string) –
A detailed explanation of the cause for the error when the execution of a state fails.
inspectionData (dict) –
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.input (string) –
The raw state input.
afterInputPath (string) –
The input after Step Functions applies the InputPath filter.
afterParameters (string) –
The effective input after Step Functions applies the Parameters filter.
result (string) –
The state’s raw result.
afterResultSelector (string) –
The effective result after Step Functions applies the ResultSelector filter.
afterResultPath (string) –
The effective result combined with the raw state input after Step Functions applies the ResultPath filter.
request (dict) –
The raw HTTP request that is sent when you test an HTTP Task.
protocol (string) –
The protocol used to make the HTTP request.
method (string) –
The HTTP method used for the HTTP request.
url (string) –
The API endpoint used for the HTTP request.
headers (string) –
The request headers associated with the HTTP request.
body (string) –
The request body for the HTTP request.
response (dict) –
The raw HTTP response that is returned when you test an HTTP Task.
protocol (string) –
The protocol used to return the HTTP response.
statusCode (string) –
The HTTP response status code for the HTTP response.
statusMessage (string) –
The message associated with the HTTP status code.
headers (string) –
The response headers associated with the HTTP response.
body (string) –
The HTTP response returned.
nextState (string) –
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.
status (string) –
The execution status of the state.
Exceptions