aws-samples / aws-samples/serverless-patterns
New pattern submission: apigw-lambda-durable-tenant-isolation-callback-terraform
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 1.1k
- Merge medio
- 7g 14h
- PR unite (30g)
- 6
Descrizione
To submit a template to the Serverless Patterns Collection, submit an issue with the following information.
IMPORTANT
Patterns are intended to be primarily IaC-focused implementations of 2-4 AWS services, with minimum custom code. They should be commonly used combinations that help developers get started quickly. If you have a utility, demo, or application, submit these to the [Serverless Repos Collection](https://serverlessland.com/repos) instead.
ONLY SUBMIT ONE PATTERN CHANGE PER PR. Multiple patterns or files spanning multiple pattern directories will be automatically rejected.
Patterns may take up to 4-6 weeks to review, test, and merge but there is no SLA and can take significantly longer due to other work the team has.
To learn more about submitting a pattern, read the [publishing guidelines page](https://github.com/aws-samples/serverless-patterns/blob/main/PUBLISHING.md).
Use the model template located at https://github.com/aws-samples/serverless-patterns/tree/main/_pattern-model to set up a README, template and any associated code.
THIS PROCESS HAS BEEN SIMPLIFIED. All the information below must be provided in the "example-pattern.json" file cloned from the model **
Description:
```
SaaS applications often process tenant requests that cannot complete in a single invocation. The workflow must pause and wait for an external system to respond — a payment gateway confirming a charge, a compliance system returning a decision, or a human approver acting on a request. During this wait, the first processing step has already validated the request and cached tenant-specific data in the execution environment's memory: configuration, credentials, computed intermediate results.
This pattern uses Lambda durable functions to suspend the workflow at zero compute cost and resume from a checkpoint when the external confirmation arrives, without re-executing completed work. It uses Lambda tenant isolation mode to ensure that the suspended execution environment — including all cached in-memory state from the first step — is never reassigned to another tenant during the wait period. Without per-tenant isolation, a different tenant's invocation could be routed to the same suspended environment, exposing one tenant's cached data to another. Without durable execution, the function cannot suspend and resume across the wait boundary, forcing you to externalize all intermediate state to a database and build a separate mechanism to trigger resumption.
The pattern deploys two API Gateway endpoints backed by two Lambda functions. The /workflow endpoint starts a durable workflow for a specific tenant — API Gateway maps the x-tenant-id header to a tenant-dedicated execution environment. The function validates the request, checkpoints progress, and suspends while logging a callback token. When the external system confirms the operation, it sends the token to the /callback endpoint, which resumes the workflow from its checkpoint. The resumed function skips all previously completed work and finishes processing with the confirmation payload. Multiple tenants can have workflows suspended simultaneously, each in a dedicated execution environment, each resuming independently when its own callback arrives.
```
Resources:
```
https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html
https://docs.aws.amazon.com/lambda/latest/dg/tenant-isolation.html
```
Framework: Terraform
Author Bio:
```
Name: Annangarachari R
Image: https://media.licdn.com/dms/image/v2/C5603AQHDdhBrpBtWsg/profile-displayphoto-shrink_800_800/profile-displayphoto-shrink_800_800/0/1651409742725?e=1759363200&v=beta&t=7-EnqmtXjWlH2uA8oSMCwnLfFFvlWtf42-aC8NSZukw
Bio: Serverless Enthusiast
linkedin: https://www.linkedin.com/in/annangarachari-r/
```
You must ensure that the sections of the model README.md are completed in full.
## GitHub PR for template:
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con _pattern-model/example-pattern.json e README.md, poi leggi PUBLISHING.md per conoscere la struttura di invio richiesta. Confronta i file completati nella pull request 3169 con il modello; il lavoro è completato quando i metadati del pattern, le sezioni del README, il template Terraform e il codice associato soddisfano le linee guida per la pubblicazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- aws, terraform
- Ambito
- api, cloud, infrastructure
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 25/100