In a serverless API using API Gateway + Lambda with a DynamoDB-backed data layer, which change best prevents accidental exposure of other tenants’ records when the tenant ID is supplied by the client?
Answer
Use an authorizer that validates the tenant identity from a trusted token and inject the tenant scope into the Lambda environment/context; enforce tenantId in every database query/update
Explanation
Best practice is to derive tenant scope from trusted identity (e.g., token claims validated by an authorizer) and enforce it server-side on every access path. Client-controlled tenant IDs are a common source of broken authorization.
Last reviewed: October 2026
Reviewed by FirstInTest Editorial Team
Related questions
You’re implementing an idempotent “create order” endpoint via API Gateway → Lambda → DynamoDB. The client may retry on network timeouts. Which approach most reliably enforces idempotency under concurrent requests?
View question →
A system ingests user events to an S3 bucket and triggers processing via S3 notifications to a Lambda function. The processor must ensure it processes each logical event once even if the notification is delivered multiple times. Which strategy is best?
View question →
A Lambda function behind an ALB needs to call a downstream HTTP service but must honor client-supplied timeouts and cap total request time. Which configuration best ensures the Lambda doesn’t exceed the ALB/Lambda integration limit and that timeouts behave predictably?
View question →
A Lambda function processes SQS messages in batches and updates DynamoDB. To ensure “at-least-once” processing doesn’t create duplicates or inconsistent state, which design is most robust?
View question →
You are designing a REST API with API Gateway and Lambda and need to minimize cold-start impact while supporting versioned deployments. Which combination is most effective?
View question →
In an AWS Lambda deployment that uses API Gateway, you need to guarantee that environment variables are treated as secrets rather than plain configuration. Which approach is best?
View question →