Skip to content

Test State

sfn_test_state R Documentation

Accepts the definition of a single state and executes it

Description

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 test_state 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 test_state API can run for up to five minutes. If the execution of a state exceeds this duration, it fails with the States.Timeout error.

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

Usage

sfn_test_state(definition, roleArn, input, inspectionLevel,
  revealSecrets)

Arguments

definition

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

roleArn

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

input

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

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.

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 test_state 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.

Value

A list with the following syntax:

list(
  output = "string",
  error = "string",
  cause = "string",
  inspectionData = list(
    input = "string",
    afterInputPath = "string",
    afterParameters = "string",
    result = "string",
    afterResultSelector = "string",
    afterResultPath = "string",
    request = list(
      protocol = "string",
      method = "string",
      url = "string",
      headers = "string",
      body = "string"
    ),
    response = list(
      protocol = "string",
      statusCode = "string",
      statusMessage = "string",
      headers = "string",
      body = "string"
    )
  ),
  nextState = "string",
  status = "SUCCEEDED"|"FAILED"|"RETRIABLE"|"CAUGHT_ERROR"
)

Request syntax

svc$test_state(
  definition = "string",
  roleArn = "string",
  input = "string",
  inspectionLevel = "INFO"|"DEBUG"|"TRACE",
  revealSecrets = TRUE|FALSE
)