Security design principles in GCP - Time & Space Complexity
When designing security in cloud systems, it is important to understand how the effort and checks grow as the system grows.
We want to know how the number of security checks or operations changes as we add more resources or users.
Analyze the time complexity of applying security policies to multiple cloud resources.
// Pseudocode for applying IAM roles to resources
for each resource in resource_list:
for each user in user_list:
grant IAM role to user on resource
This sequence assigns security roles to each user for every resource in the cloud project.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Granting IAM role to a user on a resource (API call)
- How many times: Once for every user-resource pair
As the number of users and resources grows, the total number of role assignments grows by multiplying these two numbers.
| Input Size (n users, m resources) | Approx. API Calls/Operations |
|---|---|
| 10 users, 10 resources | 100 |
| 100 users, 100 resources | 10,000 |
| 1000 users, 1000 resources | 1,000,000 |
Pattern observation: The number of operations grows quickly as both users and resources increase.
Time Complexity: O(n * m)
This means the work grows proportionally to the number of users times the number of resources.
[X] Wrong: "Adding more users or resources only adds a small, fixed amount of security work."
[OK] Correct: Each user needs permissions on each resource, so the total work multiplies, not just adds.
Understanding how security operations scale helps you design systems that stay manageable as they grow.
"What if we grouped users and assigned roles to groups instead of individual users? How would the time complexity change?"