test_state
async
¶
test_state(
definition: Definition,
*,
config_overrides: Optional[AsyncSFNClientConfig] = None,
role_arn: Optional[Arn] = None,
input: Optional[SensitiveData] = None,
inspection_level: Optional[InspectionLevel] = None,
reveal_secrets: Optional[RevealSecrets] = None,
variables: Optional[SensitiveData] = None,
state_name: Optional[TestStateStateName] = None,
mock: Optional[MockInput] = None,
context: Optional[SensitiveData] = None,
state_configuration: Optional[TestStateConfiguration] = None,
) -> TestStateOutput
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 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.
Parameters:
-
definition(Definition) –The Amazon States Language (ASL) definition of the state or state machine.
-
role_arn(Optional[Arn], default:None) –The Amazon Resource Name (ARN) of the execution role with the required IAM permissions for the state.
-
input(Optional[SensitiveData], default:None) –A string that contains the JSON input data for the state.
-
inspection_level(Optional[InspectionLevel], default:None) –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.
-
-
reveal_secrets(Optional[RevealSecrets], default:None) –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. -
variables(Optional[SensitiveData], default:None) –JSON object literal that sets variables used in the state under test. Object keys are the variable names and values are the variable values.
-
state_name(Optional[TestStateStateName], default:None) –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. -
mock(Optional[MockInput], default:None) –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.
-
context(Optional[SensitiveData], default:None) –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.
-
state_configuration(Optional[TestStateConfiguration], default:None) –Contains configurations for the state under test.
Raises:
-
InvalidArn–The provided Amazon Resource Name (ARN) is not valid.
-
InvalidDefinition–The provided Amazon States Language definition is not valid.
-
InvalidExecutionInput–The provided JSON input data is not valid.
-
ValidationException–The input does not satisfy the constraints specified by an Amazon Web Services service.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_sfn/_services/async_sfn.py
2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 | |