Skip to content

Commit 3bd3bb2

Browse files
author
purohmid
committed
updated pattern and readme
1 parent 5350e14 commit 3bd3bb2

File tree

8 files changed

+60
-9
lines changed

8 files changed

+60
-9
lines changed
-17 Bytes
Binary file not shown.

dynamodb-lambda-cdk-kotlin/.gradle/8.10/dependencies-accessors/gc.properties

Whitespace-only changes.
-1 Bytes
Binary file not shown.
-17 Bytes
Binary file not shown.

dynamodb-lambda-cdk-kotlin/.gradle/8.10/gc.properties

Whitespace-only changes.

sqs-lambda-tenant-isolation-sam-py/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Lambda Tenant Isolation with SQS
22

3-
This pattern demonstrate AWS Lambda's tenant isolation feature in Multi-tenant application.
3+
This pattern demonstrate AWS Lambda's tenant isolation feature in Multi-tenant application. It uses single SQS for multi-tenant applucation and isolating messages using messagegroupid and invoking isolated lambda enviornments.
44

55
## Key Features
66

@@ -37,7 +37,6 @@ SQS Queue → SQS Processor Lambda → Tenant-Isolated Lambda
3737

3838
```json
3939
{
40-
"customer-id": "tenant-123",
4140
"data": "your payload here"
4241
}
4342
```
@@ -56,7 +55,7 @@ Send a message to the SQS queue:
5655
```bash
5756
aws sqs send-message \
5857
--queue-url <QUEUE_URL> \
59-
--message-body '{"customer-id": "tenant-123", "data": "test payload"}'
58+
--message-body '{"data": "test payload"}'
6059
```
6160

6261

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"title": "AWS Lambda Tenant Isolation with SQS",
3+
"description": "Lambda Isolation feature",
4+
"language": "",
5+
"level": "200",
6+
"framework": "AWS SAM",
7+
"introBox": {
8+
"headline": "How it works",
9+
"text": [
10+
"This pattern demonstrate AWS Lambda's tenant isolation feature in Multi-tenant application."
11+
]
12+
},
13+
"gitHub": {
14+
"template": {
15+
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/sqs-lambda-tenant-isolation-sam-py",
16+
"templateURL": "serverless-patterns/sqs-lambda-tenant-isolation-sam-py",
17+
"projectFolder": "sqs-lambda-tenant-isolation-sam-py"
18+
}
19+
},
20+
"resources": {
21+
"bullets": [{
22+
"text": "AWS Lambda tenant isolation",
23+
"link": "https://docs.aws.amazon.com/lambda/latest/dg/tenant-isolation.html"
24+
}
25+
]
26+
},
27+
"deploy": {
28+
"text": ["sam build", "sam deploy --guided"]
29+
},
30+
"testing": {
31+
"text": ["See the GitHub repo for detailed testing instructions."]
32+
},
33+
"cleanup": {
34+
"text": ["Delete the stack: <code>sam delete</code>."]
35+
},
36+
"authors": [{
37+
"name": "Mitesh Purohit",
38+
"image": "",
39+
"bio": "Sr Solution Architect, AWS",
40+
"linkedin": "https://www.linkedin.com/in/mitup/"
41+
},
42+
{
43+
"name": "Ricardo Marques",
44+
"image": "",
45+
"bio": "Sr Serverless Specialist, AWS",
46+
"linkedin": "https://www.linkedin.com/in/ricardo-marques-aws/"
47+
}
48+
]
49+
}

sqs-lambda-tenant-isolation-sam-py/sqs-processor/index.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@
88
def handler(event, context):
99
for record in event['Records']:
1010
body = json.loads(record['body'])
11-
customer_id = body.get('customer-id')
1211

13-
if not customer_id:
14-
print(f"Missing customer-id in message: {body}")
15-
continue
12+
# Get message group ID from SQS attributes
13+
attributes = record.get('attributes') or {}
14+
message_group_id = attributes.get('MessageGroupId')
15+
16+
if not message_group_id:
17+
print(f"Missing MessageGroupId in SQS record: {record}")
18+
message_group_id = "default"
1619

1720
lambda_client.invoke(
1821
FunctionName=TENANT_ISOLATED_FUNCTION,
1922
InvocationType='Event',
2023
Payload=json.dumps(body),
21-
TenantId=customer_id
24+
TenantId=message_group_id
2225
)
2326

24-
print(f"Invoked tenant-isolated function for customer: {customer_id}")
27+
print(f"Invoked tenant-isolated function for message group: {message_group_id}")
2528

2629
return {'statusCode': 200}

0 commit comments

Comments
 (0)