Skip to content

SQL Lambda Tenant Isolation#2968

Open
devops-arch-cloud wants to merge 3 commits intoaws-samples:mainfrom
devops-arch-cloud:sqs-lambda-tenant-isolation-sam-py
Open

SQL Lambda Tenant Isolation#2968
devops-arch-cloud wants to merge 3 commits intoaws-samples:mainfrom
devops-arch-cloud:sqs-lambda-tenant-isolation-sam-py

Conversation

@devops-arch-cloud
Copy link
Copy Markdown

Issue #, if available:

Description of changes:

Multi-tenant application demonstrating AWS Lambda's tenant isolation feature.

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

@devops-arch-cloud
Copy link
Copy Markdown
Author

@marcojahn @julianwood Do you have update on this PR?

Copy link
Copy Markdown
Contributor

@marcojahn marcojahn left a comment

Choose a reason for hiding this comment

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

Hello @devops-arch-cloud, I've added a review comment, pls review.

Copy link
Copy Markdown
Author

@devops-arch-cloud devops-arch-cloud left a comment

Choose a reason for hiding this comment

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

Updated read me file

Copy link
Copy Markdown
Author

@devops-arch-cloud devops-arch-cloud left a comment

Choose a reason for hiding this comment

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

Updated readme file

Copy link
Copy Markdown
Contributor

@marcojahn marcojahn left a comment

Choose a reason for hiding this comment

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

Hello @devops-arch-cloud, i've added a few comments, pls review

@@ -0,0 +1,67 @@
# AWS Lambda Tenant Isolation with SQS
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# AWS Lambda Tenant Isolation with SQS
# AWS Lambda Tenant Isolation with Amazon SQS

@@ -0,0 +1,67 @@
# AWS Lambda Tenant Isolation with SQS

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.
Copy link
Copy Markdown
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 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.
This pattern demonstrate AWS Lambda's tenant isolation feature in Multi-tenant application. It uses single Amazon SQS for multi-tenant applucation and isolating messages using messagegroupid and invoking isolated lambda enviornments.

@@ -0,0 +1,49 @@
{
"title": "AWS Lambda Tenant Isolation with SQS",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"title": "AWS Lambda Tenant Isolation with SQS",
"title": "AWS Lambda Tenant Isolation with Amazon SQS",

(reads customer-id) (processes with tenant isolation)
```

## Testing
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Testing could be more prescriptive, e.g. (below is just a sample)

  1. You send messages to the SQS queue with --message-group-id set to a tenant identifier (e.g., tenant-blue, tenant-green)
# Get the queue URL from stack outputs
QUEUE_URL=$(aws cloudformation describe-stacks \
  --stack-name <your-stack-name> \
  --query 'Stacks[0].Outputs[?OutputKey==`QueueUrl`].OutputValue' \
  --output text)
  1. The SQS processor Lambda picks up the message, reads the MessageGroupId from the SQS record attributes, and passes it as the TenantId when invoking the tenant-isolated Lambda
# Send messages for tenant-blue
aws sqs send-message \
  --queue-url $QUEUE_URL \
  --message-body '{"data": "payload for blue"}' \
  --message-group-id "tenant-blue"
  1. Lambda routes each invocation to a dedicated execution environment for that tenant
# Send messages for tenant-green
aws sqs send-message \
  --queue-url $QUEUE_URL \
  --message-body '{"data": "payload for green"}' \
  --message-group-id "tenant-green"
  1. You verify isolation by checking CloudWatch Logs — each tenant should get its own log stream
aws logs describe-log-streams \
  --log-group-name /aws/lambda/tenant-isolated-processor \
  --order-by LastEventTime \
  --descending

- Asynchronous invocation pattern
- Automatic tenant context propagation

Learn more about this pattern at [Serverless Land Patterns](https://serverlessland.com/patterns/sqs-lambda-tenant-isolation)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Learn more about this pattern at [Serverless Land Patterns](https://serverlessland.com/patterns/sqs-lambda-tenant-isolation)
Learn more about this pattern at [Serverless Land Patterns](https://serverlessland.com/patterns/sqs-lambda-tenant-isolation-sam-py)

* [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
* [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed

## Components
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Components & How It works

  • combine
  • please be more descriptive
  • add an architecture diagram with short flow description (will replace a lot of this text)

Deployment instructions separate topic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants