AWS Builder Center
Building Zanzibar-Style Fine-Grained Authorization on AWS

Building Zanzibar-Style Fine-Grained Authorization on AWS

Build an AWS-native fine-grained authorization solution using Amazon Cognito, Amazon Verified Permissions, DynamoDB, and Cedar policies. This architecture demonstrates Zanzibar-style relationship-based access control (ReBAC) for multi-tenant applications, including resource-level owner, editor, and viewer permissions, hierarchical access, tenant isolation, temporary access, token revocation, and event-driven permission updates.

Lets Build Securely
Modern multi-tenant applications often need authorization that goes beyond static roles such as  admin ,  editor , and  viewer . A user may own one document, edit another, inherit access from a parent folder, belong to a tenant, and still be prohibited from accessing an equivalent resource in another tenant.
The solution demonstrates an AWS-native fine-grained authorization pattern that combines:
  • Amazon Cognito for authentication and identity claims.
  • Amazon Verified Permissions for policy evaluation using Cedar.
  • Amazon DynamoDB as the application-owned relationship graph.
  • AWS Lambda for authorization, token enrichment, provisioning, and event processing.
  • Amazon EventBridge for permission-change events and downstream cache invalidation.
  • AWS KMS and AWS Secrets Manager for protected application secrets and demo credentials.
  • Amazon SQS for failed cache-invalidation events.
  • Amazon CloudWatch Logs for operational visibility.
The result is a practical relationship-based access control, or ReBAC, architecture inspired by Zanzibar-style authorization while retaining explicit tenant isolation and application ownership of relationship data.
The template is described as a demo authentication, authorization, provisioning, and event-driven cache invalidation stack. It should therefore be treated as a reference implementation and starting point rather than an automatically production-ready security baseline.

The Problem This Architecture Solves

Traditional RBAC works well when permissions can be represented by a small set of global roles. It becomes harder to manage when access depends on relationships between users and individual resources.
Consider a SaaS application containing:
Tenant
|
+-- Workspace
|
+-- Project
|
+-- Folder
|
+-- Document
A user may be:
  • An owner of a workspace.
  • An editor of one project.
  • A viewer of one document.
  • A member of a group that grants access to another resource.
  • An administrator within one tenant but not another.
  • Temporarily granted access to a shared resource.
  • Explicitly denied access when the target resource belongs to another tenant.
The solution in the YAML separates these concerns into three distinct layers:
  1. Authentication answers: Who is the user?
  1. Relationship data answers: How is that user related to the resource?
  1. Policy evaluation answers: Does that relationship permit this action?
This separation is the core of the design.

End-to-End Architecture

At a high level, the solution works as follows:
User
|
v
Amazon Cognito
|
| Authenticates user
| Issues JWT
| Adds tenant claims
v
Application / API
|
| Authorization request
| principal + action + resource
v
Authorization Lambda
|
+--> Validate token / revocation state
|
+--> Read Zanzibar-style relationships from DynamoDB
|
+--> Build Verified Permissions entities
|
+--> Call Amazon Verified Permissions IsAuthorized
|
v
Cedar Policies
|
+--> Tenant isolation
+--> Owner access
+--> Editor access
+--> Viewer access
+--> Workspace admin
|
v
ALLOW or DENY
|
v
Application / API
The relationship store and policy engine are deliberately separate.
DynamoDB contains the changing relationship graph.
Amazon Verified Permissions contains the authorization model and Cedar policies.
The authorization Lambda joins those two pieces at request time.

Authentication with Amazon Cognito

The stack creates a Cognito User Pool named using the deployment environment:
 <environment>-fga-user-pool 
The allowed environments are:
  •  dev 
  •  staging 
  •  prod 
The User Pool contains standard identity attributes such as:
  •  email 
  •  given_name 
  •  family_name 
It also defines application-specific attributes:
  •  custom:tenant_id 
  •  custom:tenant_name 
  •  custom:tenant_role 
These attributes provide the identity context needed for tenant-aware authorization.

Tenant Groups

The template defines three Cognito groups:
  •  tenant-admin 
  •  tenant-member 
  •  tenant-guest 
These groups provide coarse-grained role information.
The important architectural point is that Cognito groups are not the final resource authorization mechanism. They provide identity and broad tenant context, while resource-level authorization is performed by Amazon Verified Permissions using relationship data.

OAuth Scopes

The Cognito resource server defines the following application scopes:
documents.read
documents.write
workspace.admin
The application client supports the corresponding OAuth scopes together with:
openid
email
profile
The YAML also configures access and ID token lifetime using  AccessTokenValidityMinutes , with a default of 15 minutes, and refresh-token lifetime using  RefreshTokenValidityDays , with a default of 30 days.

External OIDC Integration

The stack includes optional parameters for an external OIDC provider:
ExternalOidcIssuerUrl
ExternalOidcClientId
ExternalOidcClientSecret
When all three values are provided, the Cognito application client supports both:
COGNITO
ExternalOIDC
When they are not provided, the application uses Cognito as the supported identity provider.
This allows the same authorization architecture to be used whether users authenticate directly through Cognito or through an external OIDC identity provider federated into Cognito.

Token Enrichment

The Cognito User Pool invokes a Pre Token Generation Lambda.
Its purpose is to enrich the token with authorization-relevant identity information before the token reaches the application.
The template describes a phased authorization approach:
  1. Cognito groups and token claims provide coarse RBAC.
  1. The API calls Amazon Verified Permissions for resource-level decisions.
  1. DynamoDB relationship tuples are added to the authorization context.
  1. More advanced graph storage can be considered if the relationship hierarchy becomes significantly deeper.
The token can therefore carry convenient fast-path information such as tenant and role, while Amazon Verified Permissions remains responsible for the final fine-grained decision.

The Fine-Grained Authorization Model

The Amazon Verified Permissions policy store uses STRICT validation.
The schema defines the following entity types:
FGA::User
FGA::Group
FGA::Workspace
FGA::Project
FGA::Folder
FGA::Document
The principal is an  FGA::User .
The resource hierarchy is represented as:
Workspace
|
v
Project
|
v
Folder
|
v
Document
Each resource contains a  tenant_id .
Resources also expose sets such as:
owners
editors
viewers
Users contain:
tenant_id
tenant_role
groups
The supported actions are:
view
edit
delete
share
adminManage
This produces an authorization request conceptually similar to:
{
"principal": "FGA::User::usr-alice",
"action": "view",
"resource": "FGA::Document::doc-123"
}
The authorization service then supplies the relationship-derived entities needed by the policy engine to evaluate the request.

Cedar Policies

The template creates several static Cedar policies.

Tenant Isolation

The most important guardrail is the tenant isolation policy.
Conceptually, it says:
FORBID access
UNLESS
principal.tenant_id == resource.tenant_id
This means a user cannot gain access to a resource in another tenant simply because another relationship or role would otherwise permit the request.
Tenant isolation therefore behaves as a cross-cutting authorization boundary.

Owner Access

Owners can perform:
view
edit
delete
share
The relationship condition is based on whether the target resource's  owners  set contains the principal.

Editor Access

Editors can perform:
view
edit
They cannot obtain delete or share rights through the editor relationship.

Viewer Access

Viewers can perform:
view
The viewer relationship does not grant write, delete, or sharing capabilities.

Workspace Administration

A user with:
tenant_role == "admin"
can perform:
adminManage
on a workspace.
This demonstrates how the solution can combine role-derived attributes with resource relationships in the same authorization system.

Zanzibar-Style Relationship Store

Amazon Verified Permissions evaluates policy, but the YAML does not use the policy store itself as the persistent relationship database.
Instead, the application owns a DynamoDB table:
<environment>-authz-relationships
This table is the relationship graph.
The primary key pattern is:
PK = RESOURCE#{type}#{id}
SK = SUBJECT#{type}#{id}#RELATION#{relation}
For example:
PK = RESOURCE#Document#doc-123
SK = SUBJECT#User#usr-alice#RELATION#viewer
That tuple means:
usr-alice is a viewer of doc-123
Another example could be:
PK = RESOURCE#Project#project-100
SK = SUBJECT#User#usr-bob#RELATION#editor
That represents:
usr-bob is an editor of project-100
This tuple-oriented model makes relationships explicit and independently queryable.

Reverse Relationship Lookup

The table contains a  SubjectIndex  global secondary index.
Its key pattern is:
GSI1PK = SUBJECT#{type}#{id}
GSI1SK = RESOURCE#{type}#{id}#RELATION#{relation}
This supports the reverse question:
What resources does this subject have a relationship to?
That is useful for application functions such as:
  • Listing resources visible to a user.
  • Building user entitlement views.
  • Auditing a user's resource access.
  • Deprovisioning a user.
  • Investigating authorization relationships.

Tenant-Scoped Relationship Lookup

The table also contains a  TenantIndex .
The YAML describes this as supporting:
all relationships for tenant T
This is useful for:
  • Tenant audit.
  • Tenant offboarding.
  • Relationship inventory.
  • Administrative review.

Temporary Access

The relationship table includes an  expires_at  attribute and DynamoDB TTL.
The template uses this for time-limited guest relationships.
Conceptually:
User receives guest access
|
v
Relationship tuple created
|
+--> expires_at set
|
v
Authorization service evaluates tuple while valid
|
v
DynamoDB TTL eventually removes expired tuple
The authorization logic also checks expiration before relying on the relationship.
This provides a practical model for temporary sharing without requiring permanent policy changes.

Resource Hierarchy and Inherited Access

The Verified Permissions schema defines parent relationships:
Project.parent -> Workspace
Folder.parent -> Project
Document.parent -> Folder
The authorization service loads the resource hierarchy from DynamoDB and builds the entity data passed to Amazon Verified Permissions.
This allows the application to reason over relationships such as:
Workspace
|
+-- Project
|
+-- Folder
|
+-- Document
The inline authorization code is designed to load the resource chain and merge relevant access relationships into the target entity used for the decision.
This is how the template demonstrates hierarchical authorization without placing all authorization logic directly in the application.

Authorization Request Flow

A typical request follows this sequence.

Step 1: User Authenticates

The user signs in through Cognito or the configured external OIDC provider.
Cognito returns tokens containing identity and tenant context.

Step 2: Application Receives a Request

For example:
GET /documents/doc-123
The application determines that this maps to:
action = view
resource = Document:doc-123

Step 3: Application Calls the Authorization Service

The template exposes an  AuthorizationFunctionArn .
The output explicitly states that the Lambda can be called from:
API Gateway authorizer
or directly from the application service.
The authorization Lambda supports operations including:
check_access
batch_check
simulate_qa

Step 4: Authorization Service Loads Relationships

The Lambda reads the relevant records from the DynamoDB relationship table.
The template specifies  ConsistentRead=True  for authorization-path DynamoDB reads.
The function loads:
  • Principal relationships.
  • Resource relationships.
  • Resource ancestors.
  • Relevant group membership.
  • Tenant information.
  • Time-limited relationship state.

Step 5: Build Verified Permissions Entities

The Lambda converts application-owned DynamoDB relationship tuples into the entity structure expected by Amazon Verified Permissions.
This step is important because it creates the bridge between:
Application relationship data
and:
Cedar policy evaluation

Step 6: Call Amazon Verified Permissions

The service invokes the Verified Permissions authorization API using the configured policy store.
Conceptually:
principal = user
action = requested operation
resource = target object
entities = relationship graph needed for decision

Step 7: Cedar Policies Evaluate the Request

Amazon Verified Permissions evaluates the complete policy set.
A request can be denied because of tenant isolation even if another policy appears to grant access.
For example:
User: tenant A
Resource: tenant B
Relation: viewer
Result: DENY
The tenant isolation  forbid  policy protects the cross-tenant boundary.

Step 8: Application Enforces the Decision

The authorization result is returned to the calling service.
The application then either:
ALLOW -> continue request
or:
DENY -> stop request

Complete Runtime Flow

+----------------------+
| End User |
+----------+-----------+
|
| Sign in
v
+----------------------+
| Amazon Cognito |
| |
| User Pool |
| External OIDC |
| Tenant groups |
+----------+-----------+
|
| JWT + tenant claims
v
+----------------------+
| Application / API |
+----------+-----------+
|
| principal
| action
| resource
v
+----------------------+
| Authorization Lambda |
+----------+-----------+
|
+------------------------------+
| |
| Load relationships | Check revocation state
v v
+----------------------+ +----------------------+
| DynamoDB | | JTI Blocklist |
| Relationship Store | | DynamoDB |
+----------+-----------+ +----------------------+
|
| Build entities
v
+----------------------+
| Amazon Verified |
| Permissions |
| |
| Cedar policy store |
+----------+-----------+
|
| ALLOW / DENY
v
+----------------------+
| Application / API |
+----------------------+

Immediate Token Revocation

Short-lived tokens reduce risk, but sometimes a session must be revoked before the JWT naturally expires.
The stack therefore creates a separate DynamoDB JTI blocklist.
The architecture can check the token identifier against that table before allowing an authorization request to continue.
The YAML describes the blocklist as supporting:
immediate token revocation
and automatically expiring blocklist entries at token expiry.
This provides a way to invalidate an otherwise cryptographically valid token when immediate revocation is required.

Event-Driven Permission Changes

Changing a relationship can make cached authorization state stale.
For example:
Alice is removed as editor of Project A
If an application cache still contains the old decision, Alice may continue to appear authorized until that cache expires.
The template addresses this using DynamoDB Streams and EventBridge.
The flow is:
Relationship changed in DynamoDB
|
v
DynamoDB Stream
|
v
Cache Invalidation Lambda
|
v
Permission-change event
|
v
Amazon EventBridge
|
+--> Cache invalidation consumer
+--> Audit consumer
+--> Notification consumer
+--> Other downstream systems
The relationship table stream captures:
INSERT
MODIFY
REMOVE
events.
The  CacheInvalidationFunction  converts these records into structured permission-change events and publishes them to a dedicated EventBridge bus.

Permission-Change Event Bus

The stack creates:
<environment>-fga-permission-changes
as a custom EventBridge event bus.
Downstream services can subscribe to this bus without being tightly coupled to the relationship database.
Potential consumers include:
  • Application cache invalidation.
  • Authorization decision cache invalidation.
  • Security monitoring.
  • Audit pipelines.
  • Notifications.
  • Search-index entitlement updates.
This makes authorization updates event driven instead of relying only on cache expiration.

Event Replay and Operational Resilience

The template creates an EventBridge archive with 30-day retention.
This allows permission-change events to be retained for replay.
If a downstream consumer is unavailable or must rebuild state, the archived events provide an operational recovery mechanism for the permission-change pipeline.

Failed Cache-Invalidation Events

The DynamoDB Streams event source mapping is configured with:
MaximumRetryAttempts: 3
BisectBatchOnFunctionError: true
Failed processing is sent to an SQS dead-letter queue.
This is important because permission changes are security-sensitive events.
A failed invalidation should be visible and recoverable rather than silently disappearing.

User Provisioning

The template includes a  UserProvisioningFunction .
It supports operations including:
provision_all
provision_user
status
rotate_password
deprovision_user
smoke_test
The provisioning function creates demo users across multiple components.
The YAML describes the provisioning sequence as including:
  1. Secrets Manager.
  1. Cognito.
  1. DynamoDB relationship tuples.
  1. Verified Permissions smoke testing.
The function is designed to be idempotent so the same demo setup can be recreated without requiring manual cleanup after every deployment.

Automatic Provisioning During Stack Deployment

A CloudFormation custom resource invokes the provisioning workflow after the required resources are available.
This allows the stack to move from:
infrastructure created
to:
demo identities and relationships ready
as part of deployment.
The  RunVPSmokeTest  parameter controls whether the Verified Permissions smoke tests run after provisioning.
Its default value is:
true

Built-In Authorization Smoke Tests

The provisioning Lambda includes test cases designed to verify the complete path:
Cognito user attributes
|
v
DynamoDB relationship tuples
|
v
Verified Permissions entity data
|
v
Cedar policy
|
v
Authorization decision
The stack also exposes a  SimulationInvokeCommand  output.
After deployment, the generated command can invoke the authorization Lambda with:
{
"operation": "simulate_qa"
}
The simulation seeds sample resource and relationship data and returns authorization decisions with interpretation notes.
This is particularly useful for demonstrating the architecture without first building an application frontend.

Example Authorization Scenarios

The YAML contains demo scenarios representing users in different tenants and with different resource relationships.
The intended behavior includes patterns such as:

Tenant Administrator

A tenant administrator has administrative rights within the tenant workspace.
This does not bypass the cross-tenant isolation policy.

Resource Owner

A resource owner can:
view
edit
delete
share
the owned resource.

Resource Editor

An editor can:
view
edit
but does not receive delete or sharing permission through the editor relationship.

Resource Viewer

A viewer can:
view
only.

Cross-Tenant User

A user from another tenant is denied when accessing a resource whose  tenant_id  differs from the user's  tenant_id .
The tenant-isolation policy applies regardless of an otherwise permissive role or relationship.

Authentication and Authorization Stay Separate

One of the strongest aspects of the architecture is that authentication and authorization are not collapsed into the same mechanism.
Amazon Cognito is responsible for:
  • User authentication.
  • Federation.
  • Token issuance.
  • Identity attributes.
  • Coarse tenant roles and groups.
Amazon Verified Permissions is responsible for:
  • Authorization policy.
  •  ALLOW  or  DENY  evaluation.
  • Owner/editor/viewer semantics.
  • Tenant isolation policy.
  • Workspace administrative policy.
DynamoDB is responsible for:
  • Resource relationships.
  • Reverse subject-to-resource lookup.
  • Tenant relationship inventory.
  • Temporary grants.
  • Hierarchy data consumed by the authorization service.
This division prevents JWTs from becoming enormous containers for every fine-grained entitlement.

Why the Relationship Graph Is Application Owned

The YAML explicitly treats DynamoDB as the application's relationship store.
This means the application owns the truth about statements such as:
Alice owns Workspace A
Bob edits Project B
Charlie views Document C
Group X can access Folder D
At authorization time, the relevant subset of those relationships is converted into Verified Permissions entity data.
This pattern has several advantages:
  • Business relationship data stays in an application-controlled database.
  • Policies remain separate from resource membership data.
  • Relationship changes do not require rewriting Cedar policies.
  • Reverse lookups can be optimized independently.
  • Tenant offboarding can operate against tenant-indexed relationship data.
  • Temporary access can use DynamoDB TTL.
  • Other application features can query the same relationship graph.

Group-Based Access

The schema includes  FGA::Group , and users carry a set of group entities.
The authorization code also contains logic for resolving group members from DynamoDB.
This allows the relationship model to evolve beyond direct user-to-resource tuples.
Instead of storing only:
Alice -> viewer -> Document A
the application can model patterns in which groups participate in the relationship graph and are resolved into authorization context.
That provides a path toward collaborative SaaS use cases where access is granted to teams rather than only individual users.

Multi-Tenant Isolation

Tenant isolation is implemented at several points.

Identity Context

Cognito users contain:
tenant_id
tenant_name
tenant_role

Resource Context

Workspace, Project, Folder, and Document entities all contain:
tenant_id

Relationship Context

The DynamoDB relationship store contains a  tenant_id  attribute and a tenant-scoped index.

Policy Context

The Cedar tenant-isolation policy forbids requests unless:
principal.tenant_id == resource.tenant_id
This defense-in-depth structure makes tenant identity part of the complete authorization flow rather than relying on application URL structure or one API condition.

Data Residency

The stack is regional.
The  DataResidencyRegion  parameter is informational, and the template instructs the operator to deploy the stack in the AWS Region that satisfies the residency requirement.
The outputs specifically describe examples such as:
EU:
eu-west-1
eu-central-1
APAC:
ap-southeast-1
The template notes that the following are region scoped:
  • Cognito User Pool.
  • DynamoDB relationship table.
  • Verified Permissions policy store.
For a multi-region deployment, the template's output notes describe deploying separate stacks per Region and handling required application-owned synchronization.
The YAML does not implement an automatic multi-region active-active synchronization layer.

Migration from RBAC to Fine-Grained Authorization

The template includes a useful staged migration model.

Phase 1: Coarse RBAC

Use:
Cognito groups
+
tenant claims
+
tenant roles
for broad access control.

Phase 2: Policy-Based Authorization

Move resource-level decisions into Amazon Verified Permissions.
The API passes identity information into  IsAuthorized , and Cedar policies replace scattered conditional authorization logic.

Phase 3: Relationship-Based Authorization

Populate the DynamoDB relationship table.
The authorization service loads the appropriate tuples and converts them into Verified Permissions entities.
This is the full pattern implemented by the stack.

Phase 4: Optional Deeper Graph

The template's migration guidance suggests that a graph database such as Amazon Neptune can be considered for deeper inheritance, described as approximately four or more relationship levels.
This is presented as an optional future migration path rather than something deployed by this YAML.

Deployment Parameters

The primary parameters are:

Environment

EnvironmentName
Allowed values:
dev
staging
prod
Default:
dev

Tenant Isolation Model

TenantIsolationModel
The template currently supports:
shared-pool-with-groups
This means one Cognito User Pool is shared while tenants are logically separated using claims, groups, data, relationships, and Cedar authorization policy.

Token Lifetime

AccessTokenValidityMinutes
RefreshTokenValidityDays
Defaults:
Access token: 15 minutes
Refresh token: 30 days

External OIDC

ExternalOidcIssuerUrl
ExternalOidcClientId
ExternalOidcClientSecret
These are optional.

VPC Placement

VpcId
PrivateSubnetIds
The template includes optional VPC placement parameters for Lambda functions.

Verified Permissions Smoke Testing

RunVPSmokeTest
Default:
true

Deploying the Stack

A typical CloudFormation deployment can use:
aws cloudformation deploy \
--template-file zanzibar.yaml \
--stack-name fga-demo \
--capabilities CAPABILITY_NAMED_IAM \
--parameter-overrides \
EnvironmentName=dev \
RunVPSmokeTest=true
To deploy to a specific AWS Region:
aws cloudformation deploy \
--template-file zanzibar.yaml \
--stack-name fga-demo \
--region us-east-1 \
--capabilities CAPABILITY_NAMED_IAM \
--parameter-overrides \
EnvironmentName=dev \
DataResidencyRegion=us-east-1
 DataResidencyRegion  is informational in the template. The actual residency boundary is determined by the Region in which the CloudFormation stack is deployed.

Testing the Deployed Authorization Model

After deployment, inspect the stack output named:
SimulationInvokeCommand
The generated command invokes:
<environment>-fga-authorization-service
with:
{
"operation": "simulate_qa"
}
The equivalent invocation pattern is:
aws lambda invoke \
--function-name dev-fga-authorization-service \
--payload '{"operation":"simulate_qa"}' \
--cli-binary-format raw-in-base64-out \
simulation-output.json
Then inspect:
cat simulation-output.json
The exact function name depends on the selected  EnvironmentName .

Important CloudFormation Outputs

The stack exposes outputs that make application integration easier.

Identity Outputs

UserPoolId
UserPoolArn
UserPoolClientId
UserPoolDomain
These allow an application to configure Cognito authentication and OIDC discovery.

Authorization Outputs

PolicyStoreId
AuthorizationFunctionArn
The policy store ID is used for Verified Permissions API calls.
The authorization Lambda ARN identifies the service that the API or application can call for fine-grained authorization.

Relationship Outputs

RelationshipTableName
RelationshipTableArn
JtiBlocklistTableName
These identify the application-owned relationship and revocation stores.

Event Outputs

PermissionChangeEventBusArn
This can be used to connect cache invalidation, audit, notification, or other downstream consumers.

Provisioning Outputs

UserProvisioningFunctionArn
The provisioning Lambda can be invoked for user lifecycle and smoke-test operations supported by the template.

Security Controls Present in the Template

The YAML includes several security-relevant controls.

Strict Cedar Validation

The Verified Permissions policy store uses:
ValidationSettings:
Mode: STRICT
This helps catch policy and schema inconsistencies.

Cross-Tenant Forbid Policy

The explicit tenant-isolation  forbid  policy prevents cross-tenant access when principal and resource tenant identifiers differ.

KMS Protection

The relationship table uses a customer-managed KMS key.
The template also uses KMS-backed protection for Secrets Manager resources.

Secrets Manager

Demo user credentials are stored in Secrets Manager instead of being embedded directly in application code.

Token Revocation

A JTI blocklist provides an immediate revocation mechanism for issued tokens.

Event Failure Handling

The relationship-change pipeline has:
retries
batch bisection
SQS dead-letter queue
for failed stream processing.

CloudWatch Logging

Dedicated log groups are created for the Lambda functions.
The inline Lambda implementations contain structured operational logging and timing information for several critical steps.

Production Deletion Protection

The Cognito User Pool enables deletion protection when:
EnvironmentName = prod
The User Pool and relationship table also use CloudFormation retention behavior.

Demo Settings to Review Before Production

Because this is explicitly a demo stack, review its identity configuration before using the pattern for production.
The YAML currently contains settings including:
MfaConfiguration: OFF
and enables both OAuth authorization code and implicit flows.
It also enables Cognito advanced security in:
AUDIT
mode.
These are facts about the supplied template, not a production recommendation.
A production implementation should deliberately review the authentication configuration, application-client settings, callback URLs, federation configuration, network placement, logging, key policies, IAM permissions, and operational processes before deployment.

What This Solution Answers

Can AWS implement Zanzibar-style relationship authorization?

Yes, as an application architecture.
The template uses DynamoDB as the relationship graph, Lambda as the relationship-to-entity translation and authorization service, and Amazon Verified Permissions as the policy decision engine.
It does not claim that Verified Permissions itself is a complete Zanzibar tuple database.

Where are relationships stored?

In the application-owned DynamoDB table:
<environment>-authz-relationships

Where are authorization policies stored?

In the Amazon Verified Permissions policy store as Cedar policies.

How is tenant isolation enforced?

By carrying tenant identity through Cognito, resources, relationship data, and an explicit Cedar  forbid  policy.

Can users have different permissions on different resources?

Yes.
The relationship table can independently represent users as:
owner
editor
viewer
of individual resources.

Can the model support hierarchy?

Yes, within the hierarchy implemented by the authorization service.
The schema models:
Workspace -> Project -> Folder -> Document
and the authorization Lambda loads the resource chain when constructing authorization entities.

Can permissions be temporary?

Yes.
The relationship table includes  expires_at , and DynamoDB TTL supports cleanup of time-limited grants.

Can permission changes invalidate caches?

Yes.
The implemented path is:
DynamoDB Streams
-> Cache Invalidation Lambda
-> EventBridge
-> downstream consumers

Can authorization changes be replayed?

The stack creates an EventBridge archive with 30-day retention for permission-change events.

Can access be revoked before a JWT expires?

The architecture includes a JTI blocklist table for immediate revocation checks.

Can an external identity provider be used?

Yes, when the external OIDC issuer URL, client ID, and client secret are supplied.

Can this be deployed for regional data residency?

Yes, by deploying the complete regional stack into the required AWS Region.
The template does not implement automatic cross-region replication.

Operational Model

A practical operating model for this architecture is:
IDENTITY CHANGE
Cognito triggers
|
v
Token / provisioning updates
RELATIONSHIP CHANGE
Application writes DynamoDB tuple
|
v
DynamoDB Stream
|
v
EventBridge permission-change event
|
v
Cache / audit / notification consumers
ACCESS REQUEST
Application receives request
|
v
Authorization Lambda
|
+--> token / revocation checks
+--> DynamoDB relationship lookup
+--> hierarchy resolution
+--> build VP entities
+--> Amazon Verified Permissions
|
v
ALLOW / DENY
The key operational principle is that authorization decisions are computed from current identity context, current relationship data, and centrally managed policy.

Why This Pattern Scales Better Than Hard-Coded Authorization

Without a centralized fine-grained authorization model, applications tend to accumulate code similar to:
if admin ...
else if owner ...
else if editor ...
else if viewer ...
unless another tenant ...
unless temporary access expired ...
unless inherited from parent ...
That logic becomes difficult to audit and difficult to keep consistent across services.
This architecture moves the decision model into:
Cedar policies
+
relationship tuples
+
a common authorization service
Application services ask for a decision instead of each reimplementing the complete authorization algorithm.

Recommended Application Integration Pattern

The stack output for  AuthorizationFunctionArn  states that the authorization Lambda can be called by an API Gateway authorizer or directly from the application service.
A request pattern can therefore be:
1. Validate authentication.
2. Determine requested action and resource.
3. Call the authorization service.
4. Receive ALLOW or DENY.
5. Enforce the result before accessing business data.
For multiple resources, the Lambda also supports a  batch_check  operation.
This is useful for list pages or operations that require several authorization decisions.

Key Design Takeaways

The solution demonstrates several important fine-grained authorization principles:
  • Authentication and authorization are separate.
  • Tenant roles are not treated as sufficient for resource-level access.
  • Relationships are application data, not hard-coded policy.
  • Cedar policies express reusable authorization rules.
  • A deny boundary protects tenant isolation.
  • Hierarchy can be resolved before policy evaluation.
  • Temporary relationships can expire.
  • Token revocation can occur independently of token lifetime.
  • Permission changes can produce real-time events.
  • Authorization services can be shared across APIs.
  • Regional stacks provide a deployment model for residency requirements.
  • The architecture provides a staged path from RBAC to ReBAC/FGA.

Final Architecture Summary

The complete solution can be summarized as:
Amazon Cognito
Authentication + tenant identity
|
v
Application / API
|
v
Authorization Lambda
|
+----------------------------+
| |
v v
DynamoDB Relationship Store JTI Revocation Store
Zanzibar-style tuples Immediate revocation
|
v
Entity graph construction
|
v
Amazon Verified Permissions
Cedar policies
|
+--> tenant isolation
+--> owner
+--> editor
+--> viewer
+--> workspace admin
|
v
ALLOW / DENY
|
v
Application enforcement
Relationship updates
|
v
DynamoDB Streams
|
v
Cache Invalidation Lambda
|
v
Amazon EventBridge
|
+--> cache invalidation
+--> audit
+--> notifications
+--> downstream authorization consumers
The result is an AWS-native fine-grained authorization reference architecture in which Cognito establishes identity, DynamoDB stores relationships, Verified Permissions evaluates policy, and Lambda connects the relationship graph to the policy decision point.
For organizations moving beyond coarse RBAC, this provides a concrete path toward tenant-aware, resource-level, relationship-based authorization without forcing every application service to implement its own authorization engine.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article