AWS Public Sector Blog

Building resilient government workflows with AWS Lambda durable functions

Building resilient government workflows with AWS Lambda durable functions

When a child welfare caseworker submits a case file for AI-assisted review, the analysis pipeline must survive failures without losing progress. A dropped document can delay a safety determination by days. A retry that reprocesses an entire batch wastes budget and time that frontline workers can’t afford.

Government technology (GovTech) vendors building these multistep workflows today often code orchestration logic directly into their applications, manually implementing retry logic, state persistence, and failure recovery. This approach is brittle, expensive to maintain, and difficult to audit. Amazon Web Services (AWS) Lambda durable functions offer a code-first alternative to build fault-tolerant, long-running workflows that checkpoint automatically, retry on failure, and suspend without compute charges, all within Lambda’s existing programming model and the Federal Risk and Authorization Management Program (FedRAMP) authorization boundary.

In this post, we review how AWS Lambda works today, introduce durable functions, walk through a document processing use case for child welfare, and explain when to choose durable functions over AWS Step Functions.

What is AWS Lambda?

AWS Lambda is a serverless compute service that runs your code in response to events without creating or managing servers. You write a function, Lambda runs it on demand, and you pay only for the compute you consume. This model is a natural fit for public sector workloads because it scales automatically and removes the operational burden of managing infrastructure.

Lambda is designed for short, stateless units of work. That design comes with two constraints that matter for complex government processes: First, a single function invocation can run for a maximum of 15 minutes, so long-running jobs don’t fit into one execution. Second, functions are stateless, meaning each invocation runs independently and keeps nothing in memory from previous runs, so any progress made during an invocation is lost if the function fails or times out partway through. To coordinate work that spans minutes, hours, or days, teams have traditionally relied on external services to track state and drive retries.

What is AWS Lambda durable functions?

AWS Lambda durable functions extend the standard Lambda execution model with automatic checkpointing and replay, so a single logical workflow can run reliably for up to 1 year despite interruptions. With the open source durable execution SDK, developers wrap business logic in durable operations that persist their results. Interruptions aren’t only failures. A workflow can also pause intentionally, for example while it waits for a long-running external process to finish or for a person to review a result. In either case, when the function resumes, Lambda replays it and returns the stored results for operations that already completed, meaning work effectively continues from the last checkpoint rather than starting over.

Durable functions introduce a set of durable operations that provides a resilient workflow:

  • Steps – Run a unit of business logic and checkpoint the result, with configurable automatic retry and exponential backoff
  • Waits – Suspend execution for a set duration, from seconds to months, without consuming compute
  • Callbacks – Pause the workflow until an external system or a person provides input, which is the foundation for human-in-the-loop processes
  • Loops, parallel, and map – These patterns mean you can iterate over work, run branches concurrently, and process collections while the SDK checkpoints progress along the way

Three capabilities make this especially relevant for public sector workloads:

  1. Automatic retry with configurable backoff – Each step retries independently, which eliminates hand-coded retry logic.
  2. Suspend without compute charges – Workflows can wait for external events such as human approvals or webhook callbacks for up to 1 year without incurring idle compute costs.
  3. Full auditability – Every operation is checkpointed, which produces a durable record of what ran, when, and what it returned. This is critical for compliance and traceability requirements.

Durable functions operate within the existing Lambda FedRAMP authorization boundary and inherit Lambda Health Insurance Portability and Accountability Act (HIPAA) eligibility. Because durable functions are a feature of Lambda rather than a separate service, public sector organizations can adopt them under the existing compliance posture in Lambda with a Business Associate Agreement (BAA) in place for workloads that handle protected health information.

Where durable workflows fit in the public sector

The wait, callback, and loop operations map directly to how agencies work, where a process often pauses for a person, a records request, or a downstream system before it can continue. A few representative patterns:

  • Child welfare case review – Ingest, classify, and summarize case documents, then pause for mandatory caseworker review before any determination is made.
  • Healthcare records requests – Kick off a request to an external health information exchange and wait, sometimes for days, for patient records to arrive before resuming an eligibility or care coordination workflow.
  • Fire and Emergency Services (EMS) after-action reporting – Gather incident data from multiple systems, generate an AI-assisted draft, and hold for an officer to review and sign off.
  • Benefits and licensing onboarding – Walk an applicant through a multistep intake that waits on identity verification, document uploads, and human adjudication.

These processes are long-running, human-in-the-loop procedures that would require custom state machines and polling infrastructure to build safely.

Use case: AI-powered document review for child welfare

To see this in practice, consider child welfare document review. Child welfare agencies process thousands of documents per case, including health assessments, court transcripts, school records, and home visit reports. Government technology vendors building case management solutions must ingest, classify, and summarize these documents, then route results for mandatory human review before any determination is made.

The durable function orchestrates three steps: It extracts text from the uploaded document, classifies and summarizes the text with Amazon Bedrock, and then pauses on a callback until a caseworker completes their review. The extraction logic itself can run wherever it fits your architecture, whether that’s within a step, as a separate AWS Lambda function, or as a service such as Amazon Elastic Compute Cloud (Amazon EC2) or Amazon Elastic Container Service (Amazon ECS) because the durable function orchestrates and checkpoints the result.

In the second step, the summarization is performed by a large language model (LLM) on Amazon Bedrock, which classifies the document and produces a concise summary for the caseworker to review:

from aws_durable_execution_sdk_python import (
    DurableContext,
    StepContext,
    durable_execution,
    durable_step,
)
from aws_durable_execution_sdk_python.config import StepConfig, CallbackConfig, Duration
from aws_durable_execution_sdk_python.types import WaitForCallbackContext

# Retry policy applied to each step
STEP_CONFIG = StepConfig(max_attempts=3, initial_interval=Duration.from_seconds(5), backoff_rate=2.0)

@durable_step
def extract_text(ctx: StepContext, document_key: str) -> str:
    return extract_document_text(document_key)

@durable_step
def analyze(ctx: StepContext, extracted: str) -> dict:
    return analyze_with_bedrock(extracted)

@durable_execution
def handler(event: dict, context: DurableContext) -> dict:
    # Step 1: Extract text from the uploaded document
    extracted = context.step(extract_text(event["document_key"]), config=STEP_CONFIG)

    # Step 2: Classify and summarize using Amazon Bedrock
    analysis = context.step(analyze(extracted), config=STEP_CONFIG)

    # Step 3: Wait for caseworker review (up to 7 days, no compute charges)
    def submit(callback_id: str, ctx: WaitForCallbackContext) -> None:
        notify_caseworker(event["caseworker_email"], analysis, callback_id)

    decision = context.wait_for_callback(
        submitter=submit,
        name="caseworker-review",
        config=CallbackConfig(timeout=Duration.from_days(7)),
    )

    return {"case_id": event["case_id"], "decision": decision, "analysis": analysis}

If Amazon Bedrock returns a throttling error at the analysis step, the function retries with backoff automatically. After the wait for the caseworker review begins, the function incurs no compute charges until the callback arrives. When the function resumes after the callback arrives, the handler runs again using the checkpointed results from the first two steps rather than re-extracting the document or running the analysis again.

Durable functions must be deterministic, because the handler runs again on replay. We recommend wrapping nondeterministic work, such as generating a timestamp or a random ID or calling an external API, inside a step so that its result is checkpointed and reused rather than recomputed.

This approach eliminates the need for external state machines, checkpointing tables, or retry queues that GovTech vendors typically build and maintain themselves.

Choosing between Lambda durable functions and AWS Step Functions

AWS Step Functions is a fully managed orchestration service that defines workflows using Amazon States Language, a JSON-based definition format. Lambda durable functions keep orchestration logic in application code using the durable execution SDK.

Choose Lambda durable functions when your team prefers code-first orchestration, wants workflow logic colocated with business logic, and needs fine-grained control over retry and checkpoint behavior within a single function.

Choose AWS Step Functions when you need visual workflow design, integration with over 200 AWS services without writing Lambda functions, or distributed workflows that span multiple teams and services. For detailed guidance, explore Comparing Lambda durable functions and Step Functions in the AWS documentation.

Conclusion

AWS Lambda durable functions give GovTech vendors a code-first path to building fault-tolerant, long-running workflows without managing additional infrastructure while maintaining Lambda compliance posture. The automatic checkpointing, configurable retry, and compute-free wait capabilities map directly to public sector requirements: auditability, cost efficiency, and resilience for mission-critical processes.

The durable execution SDK is officially supported for JavaScript, TypeScript, Python, Java, and C# (.NET) so your team can adopt durable functions in the language it already uses.

You can get started today through the AWS Management Console, AWS CLI, and AWS SDKs. To learn more about how AWS supports state and local government agencies, explore AWS Cloud for State and Local Governments.

Tafadzwa Chimbindi

Tafadzwa Chimbindi

Tafadzwa is a solutions architect at AWS based in Austin, Texas. He works with GovTech customers to design and implement scalable, secure cloud solutions. Tafadzwa is passionate about software development, serverless, analytics, and observability. Outside of work, he enjoys coding, traveling, watching soccer, and reading manga.