IAM deny policies in GCP - Time & Space Complexity
We want to understand how the time to evaluate IAM deny policies changes as we add more policies or rules.
Specifically, how does checking permissions grow when there are many deny rules?
Analyze the time complexity of evaluating deny policies during an access request.
// Pseudocode for IAM deny policy evaluation
for each denyPolicy in denyPolicies:
for each denyRule in denyPolicy.rules:
if denyRule matches request:
deny access
allow access if no deny rules matched
This sequence checks all deny rules in all deny policies to decide if access should be denied.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Checking each deny rule against the access request.
- How many times: Once for every deny rule in all deny policies.
As the number of deny rules increases, the system must check more rules one by one.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | 10 rule checks |
| 100 | 100 rule checks |
| 1000 | 1000 rule checks |
Pattern observation: The number of checks grows directly with the number of deny rules.
Time Complexity: O(n)
This means the time to evaluate deny policies grows linearly with the number of deny rules.
[X] Wrong: "Adding more deny policies won't affect evaluation time much because they run in parallel."
[OK] Correct: In reality, all deny rules must be checked one after another, so more rules mean more checks and longer evaluation time.
Understanding how deny policies scale helps you design secure and efficient access controls in cloud environments.
"What if deny rules were grouped and checked using a fast lookup instead of one by one? How would the time complexity change?"