What are Resource Collections?
Resource Collections dynamically group resources based on match rules. Instead of manually adding resources to a group, you define criteria and any matching resources are automatically included. Collections are powerful for:- Applying policies to groups of resources
- Querying resources by attributes
- Building dynamic access control rules
Collection Properties
| Property | Type | Description |
|---|---|---|
id | string | Unique identifier |
scopeId | string | Scope where collection is defined |
resourceTypeId | string | Type of resources in this collection |
name | string | Display name |
description | string? | What this collection represents |
matchDefinition | ResourceMatchDefinition | Rules for matching resources |
Match Definition
ThematchDefinition object defines how resources are matched:
Creating Collections
Match by Fields
Match by Tags
Match by Patterns
Match by Time
Match by JSON Logic Condition
Combining Match Rules
All (AND)
All conditions must match:Any (OR)
Any condition can match:None (NOT)
Exclude matching resources:Complex Combinations
Using Collections with Policies
Collections are most powerful when combined with Resource Policies:Querying Collections
Get Collections for a Scope
Get Collection by ID
Collection Matching at Evaluation Time
When evaluating permissions, the engine:- Gets the resource being accessed
- Finds all collections in scope
- Evaluates each collection’s match definition against the resource
- Applies policies from matching collections
Best Practices
Keep match definitions simple
Keep match definitions simple
Complex nested rules are hard to debug. Use multiple collections if needed.
Use descriptive names
Use descriptive names
Collection names should clearly describe what resources are included.
Test match definitions
Test match definitions
Verify your match rules capture the intended resources before applying policies.
Consider performance
Consider performance
Very broad collections (matching many resources) may impact evaluation performance.
Document your collections
Document your collections
Use the description field to explain the purpose and criteria.