IAM users and groups in AWS - Time & Space Complexity
When managing AWS IAM users and groups, it is important to understand how the time to perform operations grows as you add more users or groups.
We want to know how the number of API calls changes when we create or assign many users and groups.
Analyze the time complexity of the following operation sequence.
// Create multiple IAM users
for (let i = 0; i < n; i++) {
iam.createUser({ UserName: `user${i}` }).promise();
}
// Create one IAM group
iam.createGroup({ GroupName: 'Developers' }).promise();
// Add each user to the group
for (let i = 0; i < n; i++) {
iam.addUserToGroup({ GroupName: 'Developers', UserName: `user${i}` }).promise();
}
This sequence creates n users, one group, and then adds each user to that group.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Creating users and adding users to the group.
- How many times: Creating users happens n times; adding users to the group also happens n times.
As the number of users (n) increases, the total API calls grow roughly twice as fast because each user requires two calls: one to create and one to add to the group.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 20 |
| 100 | 200 |
| 1000 | 2000 |
Pattern observation: The number of API calls grows linearly with the number of users.
Time Complexity: O(n)
This means the time to complete these operations grows directly in proportion to the number of users.
[X] Wrong: "Adding many users to a group is just one API call regardless of user count."
[OK] Correct: Each user must be added individually, so the number of calls increases with the number of users.
Understanding how operations scale with input size helps you design efficient AWS IAM management and shows you can think about system behavior as it grows.
"What if we added multiple groups and assigned each user to all groups? How would the time complexity change?"