Skip to content

feat(lambda-durable-functions): Add human-in-the-loop approval patter…#3015

Open
tafaman wants to merge 1 commit intoaws-samples:mainfrom
tafaman:human-in-the-loop-taf
Open

feat(lambda-durable-functions): Add human-in-the-loop approval patter…#3015
tafaman wants to merge 1 commit intoaws-samples:mainfrom
tafaman:human-in-the-loop-taf

Conversation

@tafaman
Copy link
Copy Markdown

@tafaman tafaman commented Apr 8, 2026

Pattern 2: Human in the Loop Pattern

Integrates human approval processes into serverless workflows. Demonstrates document submission (expense reports) requiring manager approval via email, with secure callback mechanism and automatic timeout handling.

Infrastrcuture (CDK)

  • Lambda Durable Function: Orchestrates the approval workflow
  • DynamoDB Table: Stores callback tokens with pay-per-request billing
  • SNS Topic: Sends formatted approval emails to managers
  • API Gateway: Handles callback requests from email links
  • Callback Handler: Looks up tokens and resumes execution

Workflow Steps

  1. Validate document submission
  2. Generate approval ID and store callback token in DynamoDB
  3. Send formatted approval email via SNS
  4. Pause execution with waitForCallback() (no compute charges)
  5. Manager clicks approve/reject link
  6. Callback handler looks up token from DynamoDB
  7. Resume durable execution with decision
  8. Process approval/rejection

…n with CDK

- Add complete CDK infrastructure for Lambda durable functions with human approval workflow
- Implement hitl-durable-function Lambda handler for document validation and approval requests
- Implement callback-handler Lambda for processing approval/rejection decisions
- Add DynamoDB integration for storing and retrieving callback tokens
- Add SNS integration for sending approval notification emails with callback links
- Add API Gateway endpoints for handling approval callbacks
- Include comprehensive README with deployment instructions and architecture overview
- Add sample event payloads for testing simple and large-amount scenarios
- Add Jest test configuration and CDK stack tests
- Include architecture diagrams and email notification examples
- Enables workflows to pause execution while waiting for human review without incurring compute costs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants