Least privilege principle in AWS - Time & Space Complexity
We want to understand how the effort to manage permissions grows as we add more users or resources.
How does the number of permission checks or policy updates change when the system grows?
Analyze the time complexity of applying least privilege policies to multiple users.
// Example: Assigning least privilege policies
for each user in users:
create policy with minimal permissions
attach policy to user
verify access only to allowed resources
This sequence creates and attaches a minimal permission policy for each user, ensuring they only access what they need.
Look at what repeats as users increase.
- Primary operation: Creating and attaching a policy per user.
- How many times: Once for each user.
Each new user requires a new policy and attachment.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | About 10 policy creations and attachments |
| 100 | About 100 policy creations and attachments |
| 1000 | About 1000 policy creations and attachments |
Pattern observation: The work grows directly with the number of users.
Time Complexity: O(n)
This means the effort grows in a straight line as you add more users.
[X] Wrong: "One policy can cover all users without extra work as users grow."
[OK] Correct: Using one policy for all users often gives too many permissions, breaking least privilege and risking security.
Understanding how permission management scales helps you design secure and manageable systems, a key skill in cloud roles.
"What if we grouped users by role and assigned one policy per role instead of per user? How would the time complexity change?"