Manage Executions¶
Use the AWS CLI to inspect, stop, update, and clean up durable functions and their executions.
List executions¶
Get execution details¶
Get execution history¶
View the checkpoint history for an execution:
Stop an execution¶
Stopping an execution affects the durable execution and the running Lambda invocation differently. Understanding the distinction helps you predict what happens to code that is already running.
What stopping does¶
StopDurableExecution stops the durable execution. Once stopped, the execution no
longer accepts checkpoints, nor does it start new Lambda invocations. Any operation that
was in progress stays in the STARTED state, and no further terminal checkpoints
(SUCCEEDED or FAILED) are recorded for it.
Stopping the execution does not stop the Lambda invocation that is currently running. Lambda has no mechanism to interrupt a function that is already executing, so any code that is mid-flight (for example, inside a step or a child context) keeps running.
What happens to running code¶
If your function is actively running when the execution is stopped, it continues until it reaches the next checkpoint. At that point the SDK detects that the execution has been stopped, raises an invocation error, and ends the current invocation. In practice this is usually at the end of the current block of code, when the SDK tries to checkpoint that block's result.
Note
Because the invocation runs until its next checkpoint, work that is already underway is not rolled back or cancelled. Side effects performed before the next checkpoint (for example, an external API call inside a step) still take effect. Design long-running or side-effecting steps with this in mind if you expect executions to be stopped.
Update function code¶
After updating your code, publish a new version and point your alias to it.
aws lambda update-function-code \
--function-name my-durable-function \
--zip-file fileb://function.zip
aws lambda wait function-updated \
--function-name my-durable-function
aws lambda publish-version \
--function-name my-durable-function
aws lambda update-alias \
--function-name my-durable-function \
--name prod \
--function-version <new-version>
aws lambda update-function-code \
--function-name my-durable-function \
--image-uri 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-durable-function:latest
aws lambda wait function-updated \
--function-name my-durable-function
aws lambda publish-version \
--function-name my-durable-function
aws lambda update-alias \
--function-name my-durable-function \
--name prod \
--function-version <new-version>
Running executions will continue to use the version they started with. New invocations use the updated alias.
If you're still actively developing and you don't want to publish a new version each
time you update, you could use LATEST$ just during development, but please be very
aware that executions might not replay correctly (or even fail) if the underlying code
changes during running executions. Always use numbered versions or aliases in
production.
View logs¶
Delete durable functions¶
aws lambda delete-function --function-name my-durable-function
aws iam detach-role-policy \
--role-name durable-function-role \
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicDurableExecutionRolePolicy
aws iam delete-role --role-name durable-function-role
If you deployed as a container image, also delete the image from ECR:
Replace latest with the tag you pushed if you used a different tag. To delete multiple
tags at once, specify each with a separate imageTag= argument: