What are Resource Policies?
Resource Policies provide fine-grained access control at the resource level. Unlike role-based permissions that apply broadly, policies target specific resources or collections with precise allow/deny rules. Policies are evaluated before role-based permissions, giving you a powerful override mechanism.Policy Properties
| Property | Type | Description |
|---|---|---|
id | string | Unique identifier |
scopeId | string | Scope where policy is defined |
name | string | Display name |
description | string? | What this policy does |
target | PolicyTarget | Resource or collection to target |
actions | string[] | Actions this policy applies to |
effect | PolicyEffectEnum | allow or deny |
priority | number | Higher priority = evaluated first (default: 0) |
subjectCondition | Record<string, unknown>? | JSON Logic to match the actor |
contextCondition | Record<string, unknown>? | JSON Logic to match request context |
Policy Targets
Target a Specific Resource
Target a Collection
Creating Policies
Allow Policy on a Resource
Deny Policy on a Collection
Policy with Context Condition
Policy Effects
Allow
Grants access if the policy matches:Deny
Blocks access if the policy matches. Deny policies typically have higher priority:Priority and Evaluation Order
Policies are evaluated in priority order (highest first):- Higher priority policies are checked first
- First matching policy determines the outcome
- If no policy matches, role-based permissions are checked
Subject Conditions
Match based on the actor making the request:Context Conditions
Match based on request context:Combined Conditions
Use both subject and context conditions:Evaluation Flow
WhenBedrockEngine.evaluate() is called:
Decision Output
When a policy decides the outcome:Common Patterns
Owner-Only Access
Deny All Except Admins
Temporary Access Window
Geographic Restrictions
Best Practices
Use deny policies sparingly
Use deny policies sparingly
Prefer allow policies with specific conditions. Deny policies can be hard to debug.
Set appropriate priorities
Set appropriate priorities
Use a consistent priority scheme. Example: deny=100+, allow=50, default=0.
Test policies thoroughly
Test policies thoroughly
Verify both allow and deny cases before deploying.
Document policy intent
Document policy intent
Use clear names and descriptions explaining why the policy exists.
Prefer collections over individual resources
Prefer collections over individual resources
Policies on collections are more maintainable than many individual resource policies.