0
0
AWScloud~5 mins

Least privilege principle in AWS - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Least privilege principle
O(n)
Understanding Time 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?

Scenario Under Consideration

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.

Identify Repeating Operations

Look at what repeats as users increase.

  • Primary operation: Creating and attaching a policy per user.
  • How many times: Once for each user.
How Execution Grows With Input

Each new user requires a new policy and attachment.

Input Size (n)Approx. API Calls/Operations
10About 10 policy creations and attachments
100About 100 policy creations and attachments
1000About 1000 policy creations and attachments

Pattern observation: The work grows directly with the number of users.

Final Time Complexity

Time Complexity: O(n)

This means the effort grows in a straight line as you add more users.

Common Mistake

[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.

Interview Connect

Understanding how permission management scales helps you design secure and manageable systems, a key skill in cloud roles.

Self-Check

"What if we grouped users by role and assigned one policy per role instead of per user? How would the time complexity change?"