Setup¶
The toolkit calls the real AWS test_state API for the engine logic, so two things must be
in place before anything runs. A third (Docker) is only needed if you run steps in containers.
All examples in this project use
uv— e.g.uv run --python=3.13 --with aws-stepfunctions-toolkit python run.py, which pulls the toolkit in on the fly (no virtualenv to manage). Install it first (below).
0. Install uv¶
# Ubuntu / Linux / macOS
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
(Or pip install uv / pipx install uv if you prefer.) Verify with uv --version.
1. AWS credentials and a region¶
Any standard AWS SDK setup works — the toolkit uses your ambient boto3 session. Pick one:
# Environment variables
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_SESSION_TOKEN=... # if using temporary creds
export AWS_REGION=us-east-1
# ...or a named profile / SSO
aws configure # writes ~/.aws/credentials + config
aws sso login --profile my-profile
export AWS_PROFILE=my-profile
Region resolution order: the region= argument to WorkflowRunner → AWS_REGION → your AWS
config. If none is set, boto3 raises NoRegionError.
Verify:
aws sts get-caller-identity
2. A role for test_state (the role_arn you pass)¶
test_state runs each state under an IAM execution role that you pass as role_arn. You need:
The role itself, trusted by Step Functions.
Permission for your caller to call
states:TestStateand toiam:PassRolethat role.
Create the execution role¶
trust-policy.json:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": { "Service": "states.amazonaws.com" },
"Action": "sts:AssumeRole"
}]
}
aws iam create-role \
--role-name sfn-toolkit-test-state \
--assume-role-policy-document file://trust-policy.json
For a fully mocked run (the quickstart), the role needs no extra
permissions — the mocked steps don’t actually call AWS. If you let a real integration run (e.g.
BatchJobResponseStrategy submitting a job), attach the permissions that integration needs.
The role ARN is then:
arn:aws:iam::<your-account-id>:role/sfn-toolkit-test-state
Let your caller use it¶
Attach to the user/role whose credentials you run with (from step 1):
{
"Version": "2012-10-17",
"Statement": [
{ "Effect": "Allow", "Action": "states:TestState", "Resource": "*" },
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::<your-account-id>:role/sfn-toolkit-test-state"
}
]
}
Now set role_arn to that role ARN (the only value the quickstart
asks you to edit).
3. Docker (only for container strategies)¶
Needed only if you use DockerBatchStrategy to
build/run a step’s container locally. Install Docker and make sure the daemon is running:
docker info # should succeed
Private ECR base images: pass
login_ecr=Trueto your image source, or calllogin_to_ecr(region=...)first.docker buildx bake(BakeImage): requires Buildx (bundled with modern Docker).Private package installs during build (CodeArtifact): set
codeartifact_domain/codeartifact_domain_owneronBakeImage, or fetch a token withget_codeartifact_token(...).
Troubleshooting¶
Symptom |
Fix |
|---|---|
|
Set |
|
Add |
|
Add the |
|
Fix the role’s trust policy to allow |
Docker errors from |
Ensure |