Skip to content

Commit f6282ad

Browse files
committed
Address PR review comments: fix service naming, remove duplicates, improve clarity
- Use 'Lambda durable functions' (lowercase) throughout - Use full AWS service names (Amazon API Gateway, Amazon DynamoDB, Amazon SNS) - Update regional availability note to be future-proof - Remove duplicate monitoring sections - Remove unnecessary DynamoDB monitoring section - Make deployment instructions less prescriptive - Rewrite bullet points as full sentences - Add explanation for dual timeout configuration - Update LinkedIn format to username only
1 parent 4a76eaf commit f6282ad

File tree

2 files changed

+21
-56
lines changed

2 files changed

+21
-56
lines changed

lambda-durable-human-approval-sam/README.md

Lines changed: 16 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
# Human-in-the-Loop Approval Workflow with Lambda Durable Functions
1+
# Human-in-the-Loop Approval Workflow with AWS Lambda durable functions
22

3-
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.
3+
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.
44

5-
**Important:** Lambda Durable Functions are currently available in the **us-east-2 (Ohio)** region only.
5+
**Important:** Lambda durable functions have limited regional availability. Please check the [AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html) for current regional support.
66

77
Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/lambda-durable-hitl-approval-sam
88

99
## Architecture
1010

1111
![Architecture Diagram](architecture.png)
1212

13-
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.
13+
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.
1414

1515
### Workflow Steps
1616

17-
1. **User submits approval request** via API Gateway
17+
1. **User submits approval request** via Amazon API Gateway
1818
2. **Durable Function validates request** and creates a callback
19-
3. **UUID mapping stored in DynamoDB** (callback ID → UUID)
19+
3. **UUID mapping stored in Amazon DynamoDB** (callback ID → UUID)
2020
4. **Email notification sent via SNS** with approve/reject links
2121
5. **Function pauses execution** (no compute charges during wait)
2222
6. **Approver clicks link** in email
@@ -57,16 +57,11 @@ The pattern uses Lambda Durable Functions to implement a cost-effective approval
5757
sam deploy --guided --region us-east-2
5858
```
5959

60-
During the guided deployment:
61-
- Stack Name: `lambda-durable-hitl-approval`
62-
- AWS Region: `us-east-2`
63-
- Parameter ApproverEmail: `your-email@example.com`
64-
- Confirm changes: `N`
65-
- Allow SAM CLI IAM role creation: `Y`
66-
- Disable rollback: `N`
67-
- Save arguments to config file: `Y`
60+
During the guided deployment, provide the required values:
61+
- **ApproverEmail**: Enter your email address to receive approval notifications
62+
- Allow SAM CLI to create IAM roles when prompted
6863

69-
4. **Confirm SNS subscription**: Check your email and click the confirmation link from AWS SNS
64+
4. **Confirm SNS subscription**: Check your email and click the confirmation link from Amazon SNS
7065

7166
5. Note the `ApiEndpoint` from the outputs
7267

@@ -101,24 +96,9 @@ You'll receive an email with:
10196

10297
### Click Approve or Reject
10398

104-
Click one of the links in the email. You'll see a confirmation page with:
105-
- ✓ or ✗ icon
106-
- "Request Approved!" or "Request Rejected!" message
107-
- Confirmation that the workflow has been notified
99+
Click one of the links in the email. You'll see a confirmation page that displays a checkmark or X icon along with either a "Request Approved!" or "Request Rejected!" message. The page will also confirm that the workflow has been notified of your decision.
108100

109-
### Monitor the Workflow
110101

111-
```bash
112-
# View durable function logs
113-
aws logs tail /aws/lambda/lambda-durable-hitl-approval-ApprovalFunction-XXXXX \
114-
--follow \
115-
--region us-east-2
116-
```
117-
118-
Look for:
119-
- `Starting approval workflow for request: REQ-001`
120-
- `Approval request sent. UUID: <uuid>`
121-
- `Approval workflow completed: approved` (or `rejected`)
122102

123103
## How It Works
124104

@@ -173,23 +153,13 @@ def lambda_handler(event, context):
173153
)
174154
```
175155

176-
### Cost Efficiency
177-
178-
**Traditional Lambda approach:**
179-
- Cannot wait more than 15 minutes (Lambda max timeout)
180-
- Would need Step Functions or polling mechanism
181-
- Complex state management
182-
183-
**Durable Functions approach:**
184-
- Wait up to 24 hours
185-
- No compute charges during wait
186-
- Simple, clean code
187-
- Automatic state management
188156

189157
## Configuration
190158

191159
### Adjust Timeout Duration
192160

161+
To change the timeout duration, you need to update both the Lambda function configuration and the callback configuration:
162+
193163
Modify in `template.yaml`:
194164

195165
```yaml
@@ -203,6 +173,8 @@ And in `src/lambda_function.py`:
203173
config=CallbackConfig(timeout=Duration.from_hours(24))
204174
```
205175

176+
Both values must match: `ExecutionTimeout` sets the maximum runtime for the durable function, while `CallbackConfig.timeout` sets how long the callback will wait before timing out.
177+
206178
### Change Email Address
207179

208180
Update during deployment or redeploy with new email:
@@ -237,14 +209,7 @@ aws logs tail /aws/lambda/lambda-durable-hitl-approv-CallbackHandlerFunction-XXX
237209
--follow
238210
```
239211

240-
### DynamoDB Table
241212

242-
Check the callback mappings:
243-
```bash
244-
aws dynamodb scan \
245-
--table-name lambda-durable-hitl-approval-callbacks \
246-
--region us-east-2
247-
```
248213

249214
## Cleanup
250215

@@ -255,7 +220,7 @@ sam delete --stack-name lambda-durable-hitl-approval --region us-east-2
255220

256221
## Learn More
257222

258-
- [Lambda Durable Functions Documentation](https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html)
223+
- [Lambda durable functions Documentation](https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html)
259224
- [Durable Execution SDK (Python)](https://github.com/aws/aws-durable-execution-sdk-python)
260225
- [Callback Operations](https://docs.aws.amazon.com/lambda/latest/dg/durable-callback.html)
261226
- [SendDurableExecutionCallbackSuccess API](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda/client/send_durable_execution_callback_success.html)

lambda-durable-human-approval-sam/example-pattern.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"title": "Human-in-the-Loop Approval Workflow with Lambda Durable Functions",
2+
"title": "Human-in-the-Loop Approval Workflow with Lambda durable functions",
33
"description": "Approval workflow that pauses execution while waiting for human decisions, with automatic timeout handling and callback-based resumption",
44
"language": "Python",
55
"level": "300",
66
"framework": "AWS SAM",
77
"introBox": {
88
"headline": "How it works",
99
"text": [
10-
"This pattern demonstrates a human-in-the-loop approval workflow using Lambda Durable Functions with callback operations.",
10+
"This pattern demonstrates a human-in-the-loop approval workflow using Lambda durable functions with callback operations.",
1111
"The workflow pauses execution using create_callback() while waiting for human approval, incurring no compute charges during the wait period.",
1212
"If no decision is received within 24 hours, the workflow automatically times out and rejects the request.",
1313
"When an approver submits a decision via API, the durable function resumes from its checkpoint and processes the result.",
@@ -25,7 +25,7 @@
2525
"resources": {
2626
"bullets": [
2727
{
28-
"text": "Lambda Durable Functions Documentation",
28+
"text": "Lambda durable functions Documentation",
2929
"link": "https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html"
3030
},
3131
{
@@ -36,7 +36,7 @@
3636
},
3737
"deploy": {
3838
"text": [
39-
"Note: Lambda Durable Functions are currently available in us-east-2 (Ohio) region only.",
39+
"Note: Lambda durable functions have limited regional availability. Please check the AWS documentation for current regional support.",
4040
"sam build",
4141
"sam deploy --guided --region us-east-2"
4242
]
@@ -56,7 +56,7 @@
5656
"name": "Abhishek Agawane",
5757
"image": "https://drive.google.com/file/d/1E-5koDaKEaMUtOctX32I9TLwfh3kgpAq/view?usp=drivesdk",
5858
"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.",
59-
"linkedin": "https://www.linkedin.com/in/agawabhi/"
59+
"linkedin": "agawabhi"
6060
}
6161
]
6262
}

0 commit comments

Comments
 (0)