Skip to content

Conversation

@agawanea
Copy link
Contributor

@agawanea agawanea commented Dec 3, 2025

Issue #, if available:
#2875

Description of changes:
This PR adds a new serverless pattern: Lambda Durable Functions - Human-in-the-Loop Approval Pattern

This pattern demonstrates a cost-effective human approval workflow using AWS Lambda Durable Functions. The workflow pauses execution for up to 24 hours while waiting for human approval via email, without incurring compute charges during the wait period.

Testing:
Pattern has been fully tested and deployed in us-east-2 region with successful validation of:

  • 24-hour timeout handling
  • Email notifications with working approve/reject links
  • DynamoDB TTL cleanup after expiration
  • HTML response pages with proper UTF-8 encoding
  • Callback resumption using boto3 send_durable_execution_callback_success API

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@agawanea agawanea changed the title Add Lambda Durable Functions - Human Approval Pattern New Serverless Pattern - Add Lambda Durable Functions - Human Approval Pattern Dec 3, 2025
Copy link
Contributor

@bfreiberg bfreiberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please double check the correct feature name

@@ -0,0 +1,267 @@
# Human-in-the-Loop Approval Workflow with Lambda Durable Functions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Human-in-the-Loop Approval Workflow with Lambda Durable Functions
# Human-in-the-Loop Approval Workflow with AWS Lambda durable functions

@@ -0,0 +1,267 @@
# Human-in-the-Loop Approval Workflow with Lambda Durable Functions

This pattern demonstrates a human-in-the-loop approval workflow using AWS Lambda Durable Functions. The workflow pauses execution for up to 24 hours while waiting for human approval via email, automatically handling timeouts and resuming when decisions are received.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This pattern demonstrates a human-in-the-loop approval workflow using AWS Lambda Durable Functions. The workflow pauses execution for up to 24 hours while waiting for human approval via email, automatically handling timeouts and resuming when decisions are received.
This pattern demonstrates a human-in-the-loop approval workflow using AWS Lambda durable functions. The workflow pauses execution for up to 24 hours while waiting for human approval via email, automatically handling timeouts and resuming when decisions are received.


This pattern demonstrates a human-in-the-loop approval workflow using AWS Lambda Durable Functions. The workflow pauses execution for up to 24 hours while waiting for human approval via email, automatically handling timeouts and resuming when decisions are received.

**Important:** Lambda Durable Functions are currently available in the **us-east-2 (Ohio)** region only.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will change in the near future, reword to something like "check regional availability". Also please note the name is Lambda durable functions (lowercase)


![Architecture Diagram](architecture.png)

The pattern uses Lambda Durable Functions to implement a cost-effective approval workflow that can wait up to 24 hours without incurring compute charges during the wait period.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The pattern uses Lambda Durable Functions to implement a cost-effective approval workflow that can wait up to 24 hours without incurring compute charges during the wait period.
The pattern uses Lambda durable functions to implement a cost-effective approval workflow that can wait up to 24 hours without incurring compute charges during the wait period.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct the name throughout


### Workflow Steps

1. **User submits approval request** via API Gateway
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. **User submits approval request** via API Gateway
1. **User submits approval request** via Amazon API Gateway

--follow
```

### DynamoDB Table
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

@@ -0,0 +1,62 @@
{
"title": "Human-in-the-Loop Approval Workflow with Lambda Durable Functions",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"title": "Human-in-the-Loop Approval Workflow with Lambda Durable Functions",
"title": "Human-in-the-Loop Approval Workflow with Lambda durable functions",

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct additional mentions below

"name": "Abhishek Agawane",
"image": "https://drive.google.com/file/d/1E-5koDaKEaMUtOctX32I9TLwfh3kgpAq/view?usp=drivesdk",
"bio": "Abhishek Agawane is a Security Consultant at Amazon Web Services with more than 8 years of industry experience. He helps organizations architect resilient, secure, and efficient cloud environments, guiding them through complex challenges and large-scale infrastructure transformations. He has helped numerous organizations enhance their cloud operations through targeted optimizations, robust architectures, and best-practice implementations.",
"linkedin": "https://www.linkedin.com/in/agawabhi/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"linkedin": "https://www.linkedin.com/in/agawabhi/"
"linkedin": "agawabhi"


### Click Approve or Reject

Click one of the links in the email. You'll see a confirmation page with:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reword this to full sentences instead of a bullet pointed list

Comment on lines +195 to +203
```yaml
DurableConfig:
ExecutionTimeout: 86400 # 24 hours in seconds
```

And in `src/lambda_function.py`:

```python
config=CallbackConfig(timeout=Duration.from_hours(24))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a short explanation why it needs to be changed in two places

@bfreiberg bfreiberg added the durable functions Pattern for AWS Lambda durable functions label Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

durable functions Pattern for AWS Lambda durable functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants