Lesson 4 of 4 AWS IAM

Isolating Tenant Data in Multi-Tenant Applications

This lesson explains how a multi-tenant application, which serves several customers from shared infrastructure, guarantees that no tenant can see another tenant's data.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish the silo, bridge and pool isolation models and their trade-offs.
  • Explain how session tags or scoped-down session policies enforce isolation through IAM instead of application code alone.
  • Describe how per-tenant throttling prevents one tenant from degrading the service for others.

Isolation models

A multi-tenant application serves many customers, called tenants, from one deployment, and must ensure that no tenant can read another tenant's data. There are three models, which trade the strength of isolation against cost and operational effort.

In the silo model, each tenant has dedicated resources, such as its own DynamoDB table, S3 bucket or even AWS account. Isolation is enforced by resource boundaries and simple IAM policies, and one tenant's load cannot affect another, but cost and the number of resources to manage grow with every tenant. In the pool model, tenants share the same resources, and every record carries the tenant's ID, for example as the prefix of the partition key or the S3 key. It is the cheapest and simplest to operate, but isolation depends on enforcing the tenant ID on every request. The usual technique is to assume a role with a session tag that holds the tenant ID and to use it in conditions, such as dynamodb:LeadingKeys, so that IAM rather than application code blocks access to other tenants' items. The bridge model mixes the two, for example pooled compute with a dedicated database for each premium tenant.

The following table summarises the three models.

ModelHow it worksTrade-off
SiloEach tenant has dedicated resources: its own table, bucket or accountStrongest isolation, highest cost
PoolTenants share resources; every record carries a tenant ID, such as a key prefixCheapest, but isolation must be enforced carefully
BridgeA mix, such as pooled compute with dedicated databases for premium tenantsBalances cost and isolation
Sort into groups

Silo, pool or bridge?

Exam skills 2.1.2

Recognise the three tenant isolation models and their trade-offs.

Log in to try this activity Interactive activities are free with an account.

Enforcing isolation with IAM

In pooled designs, enforce isolation with IAM, not application code alone:

  1. The tenant's identity arrives as a JWT claim, such as a Cognito custom attribute.
  2. The application assumes a role with a session tag or a scoped-down session policy for that tenant.
  3. Policy conditions, such as dynamodb:LeadingKeys or S3 prefixes containing ${aws:PrincipalTag/tenant}, restrict access to that tenant's data.

Example. One shared role limits S3 access to the prefix named by the session's tenant tag, so adding a tenant needs no new policy.

{
  "Effect": "Allow",
  "Action": ["s3:GetObject", "s3:PutObject"],
  "Resource": "arn:aws:s3:::saas-data/${aws:PrincipalTag/tenant}/*"
}
sts.assume_role(
    RoleArn="arn:aws:iam::111122223333:role/TenantAccess",
    RoleSessionName=f"tenant-{tenant_id}",
    Tags=[{"Key": "tenant", "Value": tenant_id}],
)

Per-tenant KMS keys can separate encrypted data further.

Noisy neighbours

Data isolation prevents one tenant from seeing another's data, but pooled designs also need performance isolation, so that one tenant cannot degrade the service for others. A tenant that suddenly sends far more requests than usual, known as a noisy neighbour, can consume shared capacity such as Lambda concurrency, DynamoDB throughput or database connections, causing throttling and errors for every other tenant.

The usual defence is per-tenant limits. API Gateway usage plans with an API key for each tenant enforce a request rate and quota per tenant, returning HTTP 429 to the tenant that exceeds its limit while others are unaffected. Separate SQS queues for each tenant, or SQS fair queues, stop one tenant's backlog from delaying everyone's messages. For tenants that need guaranteed capacity, the bridge model moves them to dedicated resources.

Scenario questions

Keep tenants apart

Exam skills 2.1.2 · 2.1.7

Practise data and performance isolation in a pooled design.

Log in to try this activity Interactive activities are free with an account.
Worked example

Stopping one tenant reading another's data

A SaaS application stores each tenant's files under tenants/{tenantId}/ in one bucket. A bug once let tenant A request a file belonging to tenant B. The team adds isolation that does not depend on application code being correct:

LayerControl
CredentialsFor each request, the service assumes a shared role with a session tag tenantId=A
PolicyThe role allows s3:GetObject only on tenants/${aws:PrincipalTag/tenantId}/*
ResultEven if the code asks for tenant B's file, S3 denies it

The same pattern works for DynamoDB using dynamodb:LeadingKeys on a partition key that starts with the tenant ID. Noisy tenants are contained separately, for example with per-tenant API Gateway usage plans.

Check yourself

How can one shared IAM role restrict each session to the calling tenant's S3 prefix?

Show answer

Assume the role with a session tag for the tenant, and use ${aws:PrincipalTag/tenant} in the policy's resource ARN or conditions, so each session can reach only its own prefix.

Exam Tips

Remember for the exam

  • To isolate tenants in a shared table, put the tenant ID in the key and add a LeadingKeys condition.
  • The strongest isolation is the silo model, with separate resources or accounts.
  • Use the tenant identity from a JWT claim to set session tags or a scoped session policy.
  • To stop one tenant consuming all API capacity, give each tenant its own usage plan.