AWS Lambda durable functions let a single Lambda function run a multi-step workflow for up to one year by checkpointing every step and replaying the handler from the top after each pause, skipping work that already finished. You wrap your handler with the Durable Execution SDK, put side effects inside context.step(), and use context.wait() or context.waitForCallback() to suspend without paying for compute. This tutorial builds an order workflow with a human approval callback in TypeScript, deploys it with AWS SAM, and covers the parts that break in production: determinism, versions, IAM and pricing.

Everything below was checked against the Lambda Developer Guide and the AWS Durable Execution SDK Developer Guide as of November 2026.

What durable functions are (and are not)

AWS announced durable functions on December 2, 2025 at re:Invent. At launch they ran only in US East (Ohio), with Python 3.13/3.14 and Node.js 22/24. Since then AWS has added Java, made the .NET SDK generally available on July 23, 2026, and expanded regions, including 16 more regions on April 22, 2026. Check the AWS Capabilities by Region page for your region before committing.

A durable function is still an ordinary Lambda function. What changes is that one logical run, a durable execution, can span many invocations:

  1. Your handler runs. Each step() records its result as a checkpoint.
  2. When the code reaches a wait, a callback or a scheduled retry, the SDK checkpoints and the invocation ends. You stop paying for compute.
  3. When it is time to resume, Lambda invokes the function again. The SDK replays the handler from the beginning, returns stored results for completed steps instead of running them, and continues from where it stopped.

This is the same replay model Temporal and Azure Durable Functions use, which means the same rule applies: code outside steps must be deterministic.

Supported runtimes and SDK packages

Language Managed runtimes SDK package
JavaScript / TypeScript nodejs22.x, nodejs24.x @aws/durable-execution-sdk-js
Python python3.13, python3.14 aws-durable-execution-sdk-python
Java java17, java21, java25 software.amazon.lambda.durable:aws-durable-execution-sdk-java
C# (.NET) dotnet8, dotnet10 Amazon.Lambda.DurableExecution (NuGet)

Source: Supported runtimes for durable functions. You can also use OCI container images for other runtime versions. The Node.js and Python runtimes ship a copy of the SDK, but AWS recommends bundling your own pinned version, because a new major SDK version can break in-flight executions. Java and .NET runtimes do not include it at all.

The limits that shape your design

From the Lambda quotas page and the SAM DurableConfig reference:

Limit Value
Execution timeout (ExecutionTimeout) 1 to 31,622,400 seconds (one 366-day year)
History retention after close (RetentionPeriodInDays) 1 to 90 days, default 14
Durable operations per execution 30,000 (hard limit)
Payload per durable operation 1 MB (checkpoints and callback payloads)
Total data written per execution 100 MB (hard limit)
Single invocation timeout Still 15 minutes, as for any Lambda function
Synchronous invoke Capped at 15 minutes for the whole execution

The last two rows trip people up. Each invocation is still bounded by the normal function timeout, so a single step cannot run for an hour. And if you invoke synchronously, the caller waits for the entire execution and times out after 15 minutes. Anything that waits for a human needs an asynchronous (Event) invocation.

The core API in five operations

The TypeScript SDK gives you a DurableContext with these primitives (Python has the same set in snake_case):

Operation What it does Checkpointed
context.step(name, fn, config?) Runs fn with retries, stores its return value Yes
context.wait(name, duration) Suspends for a duration; no compute billed Yes
context.waitForCallback(name, submitter, config?) Runs submitter(callbackId) as a step, then suspends until an external system completes the callback Yes
context.createCallback(name, config?) Lower-level form: returns [promise, callbackId] Yes
context.invoke(name, functionArn, payload) Calls another Lambda function (same account) and suspends until it returns Yes

There are also parallel(), map() and waitForCondition() for fan-out and polling. Durations are objects such as { seconds: 30 }, { hours: 48 } or { days: 7 } (wait reference).

Retries and step semantics

If you configure nothing, a step gets the SDK's default strategy of up to 5 retries (6 total attempts), per the retries reference. createRetryStrategy() takes maxAttempts, initialDelay, maxDelay, backoffRate, jitter, retryableErrors and retryableErrorTypes. One gotcha: if you build a strategy and do not set maxAttempts, you get the constructor default of 3 attempts, not 6.

Retry backoff is a real suspension, so you do not pay for it.

Steps default to AtLeastOncePerRetry: if the function dies after the step's side effect but before the checkpoint lands, the step runs again. For non-idempotent calls you can switch to StepSemantics.AtMostOncePerRetry, which makes the SDK throw a StepInterruptedError instead of re-running. An idempotency key on the downstream call is still the better fix.

Step 1: write the order workflow

The workflow validates an order, generates a payment idempotency key, asks a manager to approve orders of $500 or more, charges the card, waits out a one-hour cancellation window and creates the shipment.

mkdir -p order-workflow/src && cd order-workflow/src
npm init -y
npm install @aws/durable-execution-sdk-js
npm install -D typescript @types/node esbuild
// src/index.ts
import { randomUUID } from "node:crypto";
import {
  DurableContext,
  withDurableExecution,
  createRetryStrategy,
} from "@aws/durable-execution-sdk-js";
import {
  validateOrder,
  notifyApprover,
  chargeCard,
  createShipment,
  sendRejectionEmail,
} from "./services";

type OrderEvent = {
  orderId: string;
  customerEmail: string;
  amountCents: number;
};

type ApprovalDecision = {
  approved: boolean;
  approver?: string;
  reason?: string;
};

const APPROVAL_THRESHOLD_CENTS = 50_000;

const paymentRetry = createRetryStrategy({
  maxAttempts: 5,
  initialDelay: { seconds: 2 },
  maxDelay: { minutes: 1 },
  backoffRate: 2,
});

export const handler = withDurableExecution(
  async (event: OrderEvent, context: DurableContext) => {
    const order = await context.step("validate-order", async () =>
      validateOrder(event),
    );

    // Non-deterministic value: generate it inside a step so replays reuse it.
    const paymentKey = await context.step("payment-idempotency-key", async () =>
      randomUUID(),
    );

    let decision: ApprovalDecision = { approved: true, approver: "auto" };

    // Branching on the input is deterministic, so it is safe outside a step.
    if (event.amountCents >= APPROVAL_THRESHOLD_CENTS) {
      try {
        const raw = await context.waitForCallback<ApprovalDecision | string>(
          "manager-approval",
          async (callbackId) => {
            await notifyApprover({ orderId: event.orderId, callbackId });
          },
          { timeout: { hours: 48 } },
        );
        decision = typeof raw === "string" ? JSON.parse(raw) : raw;
      } catch (err) {
        // Thrown when the callback times out or the approver sends a failure.
        context.logger.warn("Approval not granted", { orderId: event.orderId });
        decision = { approved: false, reason: "approval timed out or was declined" };
      }
    }

    if (!decision.approved) {
      await context.step("notify-rejection", async () =>
        sendRejectionEmail(event.customerEmail, event.orderId, decision.reason),
      );
      return { orderId: event.orderId, status: "rejected", reason: decision.reason };
    }

    const charge = await context.step(
      "charge-card",
      async () => chargeCard(order, paymentKey),
      { retryStrategy: paymentRetry },
    );

    // Cancellation window. The function is not running (or billed) here.
    await context.wait("cancellation-window", { hours: 1 });

    const shipment = await context.step("create-shipment", async () =>
      createShipment(order, charge.chargeId),
    );

    return {
      orderId: event.orderId,
      status: "fulfilled",
      approvedBy: decision.approver,
      trackingNumber: shipment.trackingNumber,
    };
  },
);

./services is your own module (database, payment client, email). Decisions worth explaining:

  • randomUUID() lives in a step. Called in the handler body, it would produce a new value on every replay, and the payment provider would see a different idempotency key each time. AWS's determinism guide uses exactly this example.
  • The approval branch reads only event. That is deterministic. If the threshold came from a feature flag or a remote config store, you would read it inside a step, because the value could change between the first run and a replay.
  • The callback payload is parsed defensively. The waitForCallback generic defaults to string in the callback reference, while the Developer Guide examples read fields directly off the result. Handling both costs one line. You can also pass a custom serdes.
  • Step names are part of your contract. On replay the SDK matches saved state to operations. AWS's best practices warn that renaming a step or changing its behavior while executions are in flight can stop them resuming or corrupt their results.

Step 2: deploy with AWS SAM

Three things are mandatory: DurableConfig on the function, checkpoint permissions on the role, and a published version or alias. DurableConfig can only be set when the function is created. You cannot turn an existing function into a durable one, so plan for a new function name if you are migrating.

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Order workflow on Lambda durable functions

Resources:
  OrderDLQ:
    Type: AWS::SQS::Queue

  OrderWorkflow:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: order-workflow
      Runtime: nodejs22.x
      Handler: index.handler
      CodeUri: ./src
      MemorySize: 512
      Timeout: 60                  # per invocation, not per execution
      DurableConfig:
        ExecutionTimeout: 604800   # 7 days for the whole execution
        RetentionPeriodInDays: 14
      AutoPublishAlias: prod       # durable functions need a qualified ARN
      DeadLetterQueue:
        Type: SQS
        TargetArn: !GetAtt OrderDLQ.Arn
      Policies:
        - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicDurableExecutionRolePolicy
    Metadata:
      BuildMethod: esbuild
      BuildProperties:
        Target: es2022
        EntryPoints:
          - index.ts

Outputs:
  AliasArn:
    Value: !Ref OrderWorkflow.Alias
sam build
sam deploy --guided

The managed policy AWSLambdaBasicDurableExecutionRolePolicy grants lambda:CheckpointDurableExecution, lambda:GetDurableExecutionState and the CloudWatch Logs basics. The DLQ matters more than usual: AWS notes that, unlike ordinary async invocations, Lambda does not automatically retry a failed durable execution, so the DLQ is where you recover the original event. Lambda destinations are not supported for durable functions.

If you prefer CDK, lambda.Function accepts durableConfig: { executionTimeout, retentionPeriod }. Terraform needs AWS provider 6.25.0 or later for the durable_config block.

Step 3: start an execution and approve it

Invoke asynchronously, always with a qualified name, and pass an execution name as an idempotency key:

aws lambda invoke \
  --function-name order-workflow:prod \
  --invocation-type Event \
  --durable-execution-name order-10042 \
  --cli-binary-format raw-in-base64-out \
  --payload '{"orderId":"10042","customerEmail":"buyer@example.com","amountCents":72000}' \
  response.json

The execution name (1 to 64 characters, [a-zA-Z0-9-_]) makes retries safe. Re-sending the same name with the same payload returns the existing execution. A different payload under the same name fails with DurableExecutionAlreadyStartedException. Event source mappings do not support execution names, so for SQS or Kinesis triggers you need idempotency in your own code or a small dispatcher function.

Your notifyApprover implementation sends the callbackId somewhere a human can act on it, such as a Slack message with buttons or an internal admin page. The backend that receives the click completes the callback:

aws lambda send-durable-execution-callback-success \
  --callback-id "$CALLBACK_ID" \
  --cli-binary-format raw-in-base64-out \
  --result '{"approved":true,"approver":"maria@example.com"}'

# Or decline explicitly; the workflow's catch block handles it
aws lambda send-durable-execution-callback-failure \
  --callback-id "$CALLBACK_ID" \
  --error ErrorType=Declined,ErrorMessage="Over budget"

The approval service needs its own IAM permissions. Note the :* qualifier: Lambda authorizes durable execution APIs against the durable execution ARN, which always includes a version, so an unqualified function ARN never matches.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "lambda:SendDurableExecutionCallbackSuccess",
        "lambda:SendDurableExecutionCallbackFailure",
        "lambda:SendDurableExecutionCallbackHeartbeat"
      ],
      "Resource": "arn:aws:lambda:us-east-1:123456789012:function:order-workflow:*"
    }
  ]
}

To watch progress, use the Durable executions tab in the console. You can also subscribe an EventBridge rule to detail-type: "Durable Execution Status Change" with status: ["FAILED", "TIMED_OUT"] and alarm on the CloudWatch metrics DurableExecutionFailed, DurableExecutionTimedOut and DurableExecutionStorageWrittenBytes. The standard Invocations metric counts every replay.

Versions: the production footgun

Durable functions refuse unqualified invocations. You must use a version, an alias or $LATEST. An execution started on version 7 resumes on version 7 even if prod now points at version 8, so a deploy only affects new executions. $LATEST is the exception: if you update code while an execution is paused, it resumes on the new code and can fail replay. Use $LATEST for prototyping only.

The flip side is that old versions must stay deployable for as long as executions can be paused on them, which is up to your ExecutionTimeout. Do not run a cleanup job that deletes old Lambda versions without checking ApproximateRunningDurableExecutions first.

Pricing

You pay normal Lambda compute for the time your code actually runs, including replays, plus durable-specific charges. The Lambda pricing page gives these US East (N. Virginia) rates in its worked example, as of November 2026:

Dimension Price
Durable operations (starts, steps, waits, callbacks) $8.00 per million
Data written (checkpoints) $0.25 per GB
Data retained $0.15 per GB-month, prorated

AWS's own example of 1 million executions a month, each with one start, two steps and one wait, comes to $68.92 in durable charges before compute. Many tiny steps add up through operation count, so group related writes into one step when they share retry semantics, and keep RetentionPeriodInDays no longer than debugging needs.

Durable functions vs Step Functions vs Temporal vs Inngest

Lambda durable functions AWS Step Functions Temporal Inngest
Workflow definition Code (TS/JS, Python, Java, .NET) Amazon States Language / visual designer Code (Go, Java, Python, TS, .NET, Ruby, PHP, Rust SDKs) Code (step.run, step.sleep, step.waitForEvent)
Execution model Checkpoint + replay inside Lambda State machine run by the service Event history + replay on your workers Step memoization; your app is invoked per step
Max duration 1 year Up to 1 year (Standard workflows) Long-running by design (continue-as-new for long histories) 30 days (Free) to 366 days (Business) per run
Where code runs Lambda only Any AWS service via 220+ integrations Your workers, any infra Your app, any host
Hosting Fully managed Fully managed Self-host or Temporal Cloud Inngest Cloud or self-host
Lock-in AWS Lambda AWS Low (open source) Medium

AWS's own comparison page frames it as "application development in Lambda" versus "workflow orchestration across AWS." If the workflow is mostly your business logic calling your own services and you already live in Lambda, durable functions remove a whole service from the architecture. If it mostly glues AWS services together (Glue jobs, ECS tasks, Bedrock calls), Step Functions' native integrations and visual history are still better.

Against Temporal and Inngest the trade is portability versus operations. Temporal gives you the same replay model on any infrastructure, with a much larger ecosystem, at the cost of running workers and a cluster or paying for Temporal Cloud. We compare those two in Temporal vs Inngest. If you are building LLM agents rather than order pipelines, LangGraph vs Temporal for production AI agents covers the agent-specific angle, and Trigger.dev vs Temporal covers the TypeScript-first background-job option.

Frequently Asked Questions

Can I enable durable execution on an existing Lambda function?

No. AWS documents that DurableConfig is only available when you create the function. To migrate, create a new function with durable execution enabled, deploy your wrapped handler to it, and switch callers over. Keep the old function until in-flight work has drained.

What is the maximum duration of a Lambda durable function?

An execution can run for up to one 366-day year (ExecutionTimeout of 31,622,400 seconds), but only when invoked asynchronously. A synchronous invocation still caps the whole execution at 15 minutes. Each individual invocation inside the execution is also bounded by the normal 15-minute function timeout.

Do I pay while a durable function is waiting?

Not for compute. During wait, waitForCallback and retry backoff the function is not running, so there is no duration charge. You do pay for durable operations, data written and data retained, which are listed on the Lambda pricing page.

Inngest vs AWS Lambda durable functions: which should I pick?

Pick durable functions if you are already on Lambda, want no extra vendor, and are fine with AWS lock-in and the 30,000-operation limit per execution. Pick Inngest if you need to run the same workflows on Vercel, Cloudflare or your own servers, or want its event-driven triggers and dashboard across providers. Check Inngest's run-length limits: 30 days on Free, 366 days on Business. Both use step-level checkpointing, so the programming model feels similar.

Which languages support Lambda durable functions?

As of November 2026, managed runtimes cover Node.js 22 and 24 (JavaScript and TypeScript), Python 3.13 and 3.14, Java 17, 21 and 25, and .NET 8 and 10. Container images let you use other runtime versions. AWS also supports bringing a custom Durable Execution SDK.

Why does my durable function fail after a deploy?

Usually it is non-determinism. A step was renamed, reordered or removed, or code outside a step now returns something different on replay. Executions pinned to a numbered version are protected. Executions started on $LATEST are not, which is why AWS recommends versions or aliases in production.

Conclusion

Lambda durable functions are the first option that makes long-running, human-in-the-loop workflows feel native in Lambda: plain TypeScript or Python, no state machine DSL, and no paying for idle time. The rules are few but strict. Put every side effect and non-deterministic value in a named step, never rename steps that have executions in flight, invoke asynchronously through an alias, and give the function a DLQ. Follow those, and an order pipeline like the one above is about a hundred lines of code and one SAM template. If your workflow spans many AWS services or must run outside AWS, Step Functions or Temporal remain the better tools.