generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 1k
Add Lambda Durable Functions with Human-in-the-Loop pattern #2954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
4D54
wants to merge
6
commits into
aws-samples:main
Choose a base branch
from
4D54:lambda-durable-hitl-python-sam
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bebcea6
Add Lambda Durable Functions with Human-in-the-Loop pattern
4D54 e54b662
Add Lambda Durable Functions with Human-in-the-Loop pattern
4D54 7aac54f
feat: Add Lambda Durable Functions with Human-in-the-Loop pattern
4D54 5ed3a7a
Merge latest changes from upstream
4D54 5f9f3a9
Merge updated main into feature branch
4D54 6cf3423
fix: Implement callback pattern using Lambda durable execution APIs
4D54 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
| *.so | ||
| .Python | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
|
|
||
| # Virtual environments | ||
| venv/ | ||
| ENV/ | ||
| env/ | ||
| .venv | ||
|
|
||
| # Testing | ||
| .pytest_cache/ | ||
| .coverage | ||
| htmlcov/ | ||
| .hypothesis/ | ||
| *.cover | ||
| .tox/ | ||
|
|
||
| # IDEs | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # AWS SAM | ||
| .aws-sam/ | ||
| samconfig.toml | ||
|
|
||
| # Logs | ||
| *.log | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Environment variables | ||
| .env | ||
| .env.local |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| { | ||
| "title": "Lambda Durable Functions with Human-in-the-Loop", | ||
| "description": "Demonstrates Lambda durable functions with human approval workflow using Python 3.13, DynamoDB, and SNS", | ||
| "language": "Python", | ||
| "level": "300", | ||
| "framework": "SAM", | ||
| "introBox": { | ||
| "headline": "How it works", | ||
| "text": [ | ||
| "This pattern demonstrates how to pause Lambda execution, wait for human approval, and resume using the Lambda durable functions SDK.", | ||
| "The Workflow Lambda creates an approval request in DynamoDB and polls for decisions using durable waits (no compute charges during waits).", | ||
| "An SNS notification is sent to approvers, who can submit their decision via the Approval API Lambda function.", | ||
| "The Workflow Lambda detects the decision during polling and resumes execution with the approval result.", | ||
| "The pattern includes timeout handling, status tracking, and a complete audit trail of all approval decisions." | ||
| ] | ||
| }, | ||
| "gitHub": { | ||
| "template": { | ||
| "repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/lambda-durable-hitl-python-sam", | ||
| "templateURL": "serverless-patterns/lambda-durable-hitl-python-sam", | ||
| "projectFolder": "lambda-durable-hitl-python-sam", | ||
| "templateFile": "template.yaml" | ||
| } | ||
| }, | ||
| "resources": { | ||
| "bullets": [ | ||
| { | ||
| "text": "Lambda Durable Functions Documentation", | ||
| "link": "https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html" | ||
| }, | ||
| { | ||
| "text": "AWS SAM Documentation", | ||
| "link": "https://docs.aws.amazon.com/serverless-application-model/" | ||
| }, | ||
| { | ||
| "text": "DynamoDB Best Practices", | ||
| "link": "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/best-practices.html" | ||
| }, | ||
| { | ||
| "text": "Amazon SNS Documentation", | ||
| "link": "https://docs.aws.amazon.com/sns/" | ||
| } | ||
| ] | ||
| }, | ||
| "deploy": { | ||
| "text": [ | ||
| "sam build", | ||
| "sam deploy --guided" | ||
| ] | ||
| }, | ||
| "testing": { | ||
| "text": [ | ||
| "See the README in the GitHub repo for detailed testing instructions.", | ||
| "Test the approval workflow using AWS CLI:", | ||
| "1. Publish Lambda version: aws lambda publish-version --function-name <WorkflowFunction>", | ||
| "2. Invoke workflow: aws lambda invoke --function-name <WorkflowFunction>:<version> --invocation-type Event --payload '{...}' response.json", | ||
| "3. List approvals: aws dynamodb scan --table-name <ApprovalsTable>", | ||
| "4. Submit decision: aws lambda invoke --function-name <ApprovalApiFunction> --payload '{\"action\":\"decide\",...}' response.json" | ||
| ] | ||
| }, | ||
| "cleanup": { | ||
| "text": [ | ||
| "Delete the stack: sam delete" | ||
| ] | ||
| }, | ||
| "authors": [ | ||
| { | ||
| "name": "Mian Tariq", | ||
| "bio": "Cloud Solutions Architect" | ||
| } | ||
| ], | ||
| "patternArch": { | ||
| "icon1": { | ||
| "name": "lambda", | ||
| "label": "Lambda Durable Functions" | ||
| }, | ||
| "icon2": { | ||
| "name": "dynamodb", | ||
| "label": "Amazon DynamoDB" | ||
| }, | ||
| "icon3": { | ||
| "name": "sns", | ||
| "label": "Amazon SNS" | ||
| } | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
lambda-durable-hitl-python-sam/src/approval_api/Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| FROM public.ecr.aws/lambda/python:3.13 | ||
|
|
||
| # Copy requirements file | ||
| COPY approval_api/requirements.txt ${LAMBDA_TASK_ROOT}/ | ||
|
|
||
| # Install dependencies | ||
| RUN pip install --no-cache-dir -r requirements.txt | ||
|
|
||
| # Copy function code | ||
| COPY approval_api/app.py ${LAMBDA_TASK_ROOT}/ | ||
| COPY shared/*.py ${LAMBDA_TASK_ROOT}/ | ||
|
|
||
| # Set the CMD to your handler | ||
| CMD ["app.lambda_handler"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the pattern structure: https://github.com/aws-samples/serverless-patterns/tree/main/_pattern-model
Especially form/format and order of the Readme.md.
Besides the above:
Architecture, Components, Execution Flow -> one Architecture diagram + one small explanation of the flow (see other references as example)
Project structure -> can be removed
Folder purposes -> can be removed
Key Files -> can be removed
Important Notes -> can be removed (if you wish, add it very briefly to the pattern description, see template Readme.md)
Running Unit Tests / property based tests -> can be removed (unit tests itself are not mandatory for serverless patterns)
Use Cases -> can be removed (if you wish, add it very briefly to the pattern description, see template Readme.md OR reference the official docs examples page)
Security Considerations -> can be removed
Cost Considerations -> see template Readme.md
Limitations -> can be removed OR briefly add to pattern description
Additional resources -> can be removed. Useful links can be added to the description and text
License -> please see template Readme.me