API reference¶
Every public symbol is importable directly from the top-level aws_stepfunctions_toolkit
package — there are no deep import paths. The reference below is generated from the source
docstrings and tracks __all__, so it always matches what the package actually exports.
from aws_stepfunctions_toolkit import WorkflowRunner, DockerBatchStrategy, DockerfileImage
AWS Step Functions Toolkit.
Run Step Functions state machines end-to-end on your machine: the toolkit walks the
state machine, uses the AWS test_state API for the engine-side logic
(Path/Parameters/ResultSelector/next-state), and lets you plug in strategies for the
states the test API can’t run remotely (.sync Batch jobs, .waitForTaskToken) —
typically by building and running their container locally via Docker.
Everything you need is importable from this top-level package.
- class aws_stepfunctions_toolkit.DockerBatchStrategy(s3_bucket, image_source, execution_id=None, volumes=None, variables=None, user=None, gpus=None, extra_run_envs=None, region=None, s3_client=None)[source]¶
Bases:
StateExecutionStrategyRuns a Batch (or any container) task locally via Docker.
The image is produced by a pluggable
ImageSource(DockerfileImagefor a plain Dockerfile build,PrebuiltImagefor an existing/ECR image,BakeImagefordocker buildx bake, or your own). This strategy only resolves the container’s Command/Environment from the state, runs the container, and reads its output.The container is expected to write its result JSON to
/tmp/output.json(the toolkit mounts a writable temp dir at/tmpand injectsOUTPUT_PATH/S3_OUTPUT_PATH).
- aws_stepfunctions_toolkit.BatchImageStrategy¶
alias of
DockerBatchStrategy
- aws_stepfunctions_toolkit.LocalBatchImageStrategy¶
alias of
DockerBatchStrategy
- class aws_stepfunctions_toolkit.LocalExecutionStrategy(entrypoint=None, s3_bucket=None, execution_id=None, cwd=None, extra_env=None, inherit_env=True, variables=None)[source]¶
Bases:
StateExecutionStrategyRun a step locally as a subprocess — directly in your terminal, no Docker.
This is the no-Docker counterpart to
DockerBatchStrategy: it resolves the step’sCommand+Environmentfrom the ASL (via the test API), prependsentrypoint(the program to run — the local equivalent of a container’s ENTRYPOINT), injectsOUTPUT_PATH(a temp file) andS3_OUTPUT_PATH, removesTaskToken, runs the process, and reads the result JSON the process writes toOUTPUT_PATH.The same job code (e.g. one using
BatchJobInterface) runs unchanged here or in a container, since both honor theOUTPUT_PATHcontract.LocalExecutionStrategy(entrypoint=[“python”, “jobs/process_data/main.py”])
- class aws_stepfunctions_toolkit.CallableStrategy(handler)[source]¶
Bases:
StateExecutionStrategyWrap a plain function as a strategy — the simplest way to define your own handler.
handlerreceives the state’s input dict and returns the state’s result either as a dict/list (json-encoded for you) or as a pre-serialized JSON string.CallableStrategy(lambda input_data: {“ok”: True, “echo”: input_data})
- class aws_stepfunctions_toolkit.StaticMockResponseStrategy(result)[source]¶
Bases:
StateExecutionStrategyReturns a fixed, caller-supplied JSON string as the state’s result.
- Parameters:
result (str)
- class aws_stepfunctions_toolkit.BatchJobResponseStrategy(job_queue, job_definition, job_name=None, batch_client=None, variables=None, region=None)[source]¶
Bases:
StateExecutionStrategySubmits a real AWS Batch job (rather than running the container locally).
- class aws_stepfunctions_toolkit.GetLatestConfigurationStrategy(application, environment, configuration_profile, appconfigdata_client=None, region=None)[source]¶
Bases:
StateExecutionStrategyResolves a state’s result from AWS AppConfig (start session + get latest configuration).
- class aws_stepfunctions_toolkit.AbstractMockMapResponseStrategy[source]¶
Bases:
StateExecutionStrategy,ABCBase for Map states: implement
get_itemsto supply the items to iterate.Each item is run through the Map’s ItemProcessor via
run_sub_machine.
- class aws_stepfunctions_toolkit.StandardFlowStrategy[source]¶
Bases:
StateExecutionStrategyHandles Map, Parallel, and Nested SMs via recursion.
- aws_stepfunctions_toolkit.get_container_overrides(sfn_client, state_def, role_arn, variables, input_data, context)[source]¶
Use the test API to resolve a Batch task’s ContainerOverrides (Command + Environment).
Runs
test_statein TRACE mode with an empty mock so AWS evaluates the state’s Arguments/Parameters, then returns the resolvedContainerOverrides.
- class aws_stepfunctions_toolkit.ImageSource[source]¶
Bases:
ABCProduces a locally-runnable Docker image reference.
- class aws_stepfunctions_toolkit.PrebuiltImage(image, login_ecr=False, region=None)[source]¶
Bases:
ImageSourceRun an image that already exists (local tag or a registry/ECR reference).
Set
login_ecr=Trueto authenticate to ECR before the (implicit) pull.
- class aws_stepfunctions_toolkit.DockerfileImage(context, dockerfile=None, build_args=None, tag=None, target=None, region=None, login_ecr=False)[source]¶
Bases:
ImageSourceBuild an image from a plain Dockerfile + build context (the common dev path).
contextis the build-context directory.dockerfiledefaults to<context>/Dockerfile.tagis auto-generated if not given.- Parameters:
- class aws_stepfunctions_toolkit.BakeImage(bake_file, target, tag=None, base_dir=None, bake_variables=None, codeartifact_domain=None, codeartifact_domain_owner=None, region=None)[source]¶
Bases:
ImageSourceBuild an image via
docker buildx bake(advanced / monorepo setups).Optionally injects a
BASE_DIRbake variable (base_dir) and aCODEARTIFACT_AUTH_TOKENbake variable (when both codeartifact_* are set, for private package installs during the build).- Parameters:
- aws_stepfunctions_toolkit.login_to_ecr(region=None)[source]¶
Authenticate the local Docker daemon against the caller’s ECR registry.
- aws_stepfunctions_toolkit.get_codeartifact_token(domain, domain_owner, region=None)[source]¶
Fetch an AWS CodeArtifact authorization token (e.g. to inject into a Docker build).
- class aws_stepfunctions_toolkit.ExecutionContext(*, Execution=_Execution(Id='String', Input='{}', Name='String', RoleArn='String', StartTime='2025-12-14T18:00:00Z', RedriveCount=12, RedriveTime='2025-12-14T18:00:00Z'), State=_State(EnteredTime='2025-12-14T18:00:00Z', Name='String', RetryCount=12), StateMachine=_StateMachine(Id='String', Name='String'), Task=None)[source]¶
Bases:
BaseModel- Parameters:
Execution (_Execution)
State (_State)
StateMachine (_StateMachine)
Task (_Task | None)
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class aws_stepfunctions_toolkit.StartExecutionResult(*, OutputDetails={'Included': False}, Input='', ExecutionArn='arn:aws:states:us-east-1:000000000000:execution:ExampleStateMachine:test', RedriveCount=0, InputDetails={'Included': False}, RedriveStatus='NOT_REDRIVABLE', RedriveStatusReason='Execution is SUCCEEDED and cannot be redriven', StartDate='1769015654832', StateMachineArn='arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStateMachine', Status='SUCCEEDED', StopDate='1769015943200', Output='{}')[source]¶
Bases:
BaseModel- Parameters:
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class aws_stepfunctions_toolkit.AslDefinition(*, StartAt, States, **extra_data)[source]¶
Bases:
BaseModel- model_config = {'extra': 'allow'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class aws_stepfunctions_toolkit.DockerBatchConfig(*, s3_bucket, bake_file, volumes=[], variables={}, target_mapping, user=None)[source]¶
Bases:
BaseModel- Parameters:
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class aws_stepfunctions_toolkit.ExecutionHistory(events)[source]¶
Bases:
objectIterator for Step Functions execution history events.
- Parameters:
events (list[HistoryEventTypeDef])
- class aws_stepfunctions_toolkit.EventFilter(events)[source]¶
Bases:
objectFilter methods for execution history events.
- Parameters:
events (list[HistoryEventTypeDef])
- aws_stepfunctions_toolkit.generate_mock_data(execution_arn, output_dir=None, region=None, sfn_client=None)[source]¶
Generate mock data files from Step Functions execution.
- class aws_stepfunctions_toolkit.BatchJobInterface(logger=None, task_token_env_var='TaskToken', output_path_env_var='OUTPUT_PATH', test_mode_env_var='ENVIRONMENT', test_mode_values=('dev', 'test'), region=None)[source]¶
Bases:
ABC,Generic[InputT,OutputT]- Parameters:
- abstractmethod should_run(input_data)[source]¶
Return True if the job should actually do its work for this input.
- Parameters:
input_data (InputT)
- Return type:
- class aws_stepfunctions_toolkit.BasicJobInput(*, last_step_results, force=False)[source]¶
Bases:
BaseModel- Parameters:
last_step_results (LastStepResults)
force (bool)
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].