Runs a lambda:invoke step by executing the Lambda's real container image locally, instead
of hand-writing a mock. DockerLambdaStrategy
builds the image from a plain Dockerfile (DockerfileImage),
runs it detached with the AWS Runtime Interface Emulator (RIE) port published, POSTs the
resolved event Payload, and returns the handler's real output — the Lambda counterpart to
DockerBatchStrategy.
The AWS Lambda base images (public.ecr.aws/lambda/python:*, etc.) ship the RIE, so no extra
tooling is needed: the strategy POSTs the event to
/2015-03-31/functions/function/invocations.
asl_definitions/main.asl.json— onelambda:invokestate. ItsOutputkeeps the real$states.result.Payloadexpression; the runner rewrites it to$parse(...)for the mocked step (the mocked result'sPayloadis a JSON string).project_file/echo_lambda/— a tiny Lambda image: anapp.pyhandler that doublesnumberand echoes the event, plus a minimal Dockerfile.run.py— wires the step toDockerLambdaStrategy.
- Docker running — this example builds and runs a real Lambda container (
docker infomust work). - AWS credentials + a region and an IAM role allowed to call
test_state— see the Setup guide.
- Set your
test_staterole:export ROLE_ARN=arn:aws:iam::<account>:role/<your-test-state-role>(or edit the default in the script). - Run it:
uv run --python=3.13 --with aws-stepfunctions-toolkit python run.pyExpected output:
{
"doubled": 42,
"echo": { "number": 21 }
}