
AWS Lambda Durable Execution SDK for Rust Is Now GA, So I Tried It Out
This page has been translated by machine translation. View original
Introduction
On November 19, 2026, the general availability (GA) of the AWS Lambda Durable Execution SDK for Rust was announced.
With this SDK, you can write Lambda durable functions logic as ordinary async Rust functions. This article walks through deploying the Quickstart function and checking the execution records.
Test Environment
The SDK requires Rust 1.94.1 or later. The environment used for this test is as follows.
- Test date: November 20, 2026
- Region: Tokyo (ap-northeast-1)
- Function architecture: x86_64
- Runtime: provided.al2023
- aws-durable-execution-sdk 1.0.0, lambda_runtime 1.5.0
- rustc / cargo 1.96.1, Cargo Lambda 1.9.2
- AWS CLI 2.41.2
- The build was run in Docker on an aarch64 Linux host
The Docker image is rust:1.96-bookworm with Cargo Lambda installed via pip. The cargo and cargo lambda commands were run inside a container of this image.
Dockerfile for the build
Save it as Dockerfile and create the image with docker build -t durable-rust-build ..
FROM rust:1.96-bookworm
# Install cargo-lambda with pip3 as per the official instructions (Zig is installed along with it)
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3-venv \
&& rm -rf /var/lib/apt/lists/* \
&& python3 -m venv /opt/venv \
&& /opt/venv/bin/pip install --no-cache-dir cargo-lambda \
&& rustup target add x86_64-unknown-linux-gnu
ENV PATH="/opt/venv/bin:${PATH}"
Implementing the Function
Create a project and add the required crates.
cargo new my-function && cd my-function \
&& cargo add aws-durable-execution-sdk \
&& cargo add lambda_runtime serde_json tracing \
&& cargo add serde --features derive \
&& cargo add tokio --features macros
Place the Rust version of the Quickstart handler in src/main.rs.
use std::time::Duration;
use aws_durable_execution_sdk as durable;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct Response {
status_code: u16,
body: String,
}
async fn handler(
_event: serde_json::Value,
ctx: durable::DurableContext,
) -> Result<Response, durable::BoxError> {
let message = ctx
.step(|_| async {
tracing::info!("Hello from step-1");
Ok("Hello from Durable Lambda!".to_owned())
})
.name("step-1")
.await?;
ctx.wait(Duration::from_secs(10)).await?;
// Replay-aware: logs once even though the function replays after the wait
tracing::info!("Resumed after wait");
Ok(Response {
status_code: 200,
body: message,
})
}
#[tokio::main]
async fn main() -> Result<(), lambda_runtime::Error> {
durable::init_default_subscriber()?;
durable::run(handler).await
}
The key points of the code are as follows.
- Handler: An ordinary async function that receives an event and a DurableContext and returns a Result. The event type needs Deserialize and the output type needs Serialize, and the SDK converts them with serde_json.
- step: A unit whose result is saved. If you give it a name, it appears under that name in the execution history.
- wait: Pauses execution for the specified duration.
- main: Configures log output with init_default_subscriber and passes the handler to durable::run.
Besides step and wait, you can use invoke, wait_for_callback, wait_for_condition, map, parallel, and with_retry. The options and return values of each operation are listed in the reference linked from the official guide.
Build and Deploy
The build is done with Cargo Lambda.
cargo lambda build --release --x86-64 --output-format zip
The output is target/lambda/my-function/bootstrap.zip.
According to the official guide, the glibc in provided.al2023 is 2.34, and a binary built with plain cargo build that links against a newer glibc fails at startup. Cargo Lambda links via Zig to pin the glibc version. This is why Cargo Lambda is used for builds targeting provided.al2023.
Create the execution role. Save the trust policy as trust-policy.json, and attach the managed policy after creating the role.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Service": "lambda.amazonaws.com" },
"Action": "sts:AssumeRole"
}
]
}
aws iam create-role \
--role-name devio-rust-durable-verify-role \
--assume-role-policy-document file://trust-policy.json
aws iam attach-role-policy \
--role-name devio-rust-durable-verify-role \
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicDurableExecutionRolePolicy
Contents of AWSLambdaBasicDurableExecutionRolePolicy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"lambda:CheckpointDurableExecution",
"lambda:GetDurableExecutionState"
],
"Resource": "*"
}
]
}
Create the function with create-function. This time, we specify --durable-config at creation to make it a durable function.
aws lambda create-function \
--function-name rust-durable-quickstart \
--runtime provided.al2023 \
--role arn:aws:iam::123456789012:role/devio-rust-durable-verify-role \
--handler bootstrap \
--architectures x86_64 \
--zip-file fileb://target/lambda/my-function/bootstrap.zip \
--durable-config '{"ExecutionTimeout": 900, "RetentionPeriodInDays": 1}'
Immediately after creation, the State was Pending, so I waited until it became Active before invoking.
aws lambda wait function-active-v2 --function-name rust-durable-quickstart
Synchronous invoke and Execution Records
Invoke the function synchronously.
aws lambda invoke \
--function-name 'rust-durable-quickstart:$LATEST' \
--cli-binary-format raw-in-base64-out \
--payload '{}' \
response.json
{
"StatusCode": 200,
"ExecutedVersion": "$LATEST",
"DurableExecutionArn": "arn:aws:lambda:ap-northeast-1:123456789012:function:rust-durable-quickstart:$LATEST/durable-execution/<execution-name>/<execution-id>"
}
response.json contained the handler's return value.
{"statusCode":200,"body":"Hello from Durable Lambda!"}
The response came back at 01:01:40 (UTC). The DurableExecutionArn is used to specify the execution in get-durable-execution and get-durable-execution-history, described later.
I first retrieved the execution records with filter-log-events in CloudWatch Logs.
aws logs filter-log-events --log-group-name /aws/lambda/rust-durable-quickstart
The following table lists the 7 events in chronological order. Times are in UTC.
| Time | Type | Details |
|---|---|---|
| 01:01:27.765 | platform.initStart | initializationType: on-demand |
| 01:01:27.827 | platform.start | 1st invocation |
| 01:01:28.682 | App log | Hello from step-1 (operationName: step-1, attempt: 1) |
| 01:01:30.056 | platform.report | status: success |
| 01:01:40.122 | platform.start | 2nd invocation |
| 01:01:40.123 | App log | Resumed after wait (no operationName) |
| 01:01:40.124 | platform.report | status: success |
A single execution was split into two Lambda invocations, with the wait in between. The first ended at 01:01:30.056, and the second started at 01:01:40.122. The step log was output only in the first invocation.
The log of the second invocation was ingested into CloudWatch Logs at 01:01:49.137, about 9 seconds after it occurred at 01:01:40.122. I ran filter-log-events at 01:01:52, about 12 seconds after the response, so all 7 events were available.
The status in the 7 events is that of the platform.report for each invocation. The status and end time of the durable execution as a whole are retrieved with get-durable-execution.
aws lambda get-durable-execution --durable-execution-arn "<DurableExecutionArn>"
The following shows the Result, start time, Status, and end time extracted from the response. Times returned in +09:00 have been converted to UTC.
{
"Result": "{\"statusCode\":200,\"body\":\"Hello from Durable Lambda!\"}",
"StartTimestamp": "2026-11-20T01:01:27.567000Z",
"Status": "SUCCEEDED",
"EndTimestamp": "2026-11-20T01:01:40.132000Z"
}
This single execution took about 12.6 seconds from start to finish.
The execution history is retrieved with get-durable-execution-history.
aws lambda get-durable-execution-history --durable-execution-arn "<DurableExecutionArn>"
The EventTypes in Events were listed in the following order.
ExecutionStarted
StepStarted
StepSucceeded
WaitStarted
InvocationCompleted
WaitSucceeded
InvocationCompleted
ExecutionSucceeded
InvocationCompleted was recorded twice.
Summary
With the now-GA AWS Lambda Durable Execution SDK for Rust, I confirmed that you can write durable functions as ordinary async functions.
If you are considering Lambda durable functions, which can handle long-running tasks, as the execution environment for a workload implemented in Rust, give the newly GA SDK a try.
