Sub topic 7
Organizing users with groups
This chapter assumes you can read IAM policy JSON, know what an IAM user is, and understand how identity-based policies attach to identities. Here you will see how groups let you manage permissions for many users in one place.
What a group is
An IAM group is a collection of IAM users. You attach identity-based policies to the group, and every member receives those permissions. A group is not a principal. It has no credentials, you cannot sign in as a group, and it cannot be named as a Principal in a trust policy or resource-based policy. It only exists to make permission management easier.
Groups have these properties:
- A user can belong to several groups, and their permissions add together.
- A group can contain only users. Groups cannot contain other groups, so there is no nesting.
- A group can have AWS managed policies, customer managed policies, and inline policies attached, like a user.
- There is no default group that holds all users. Create one yourself if you need it.
- A new user has no permissions until you add them to a group or attach a policy directly.
Creating and using a group
The following commands create a group, attach an AWS managed policy, and add a user to it.
aws iam create-group --group-name Developers
aws iam attach-group-policy \
--group-name Developers \
--policy-arn arn:aws:iam::aws:policy/PowerUserAccess
aws iam add-user-to-group \
--group-name Developers \
--user-name dev-user
aws iam get-group --group-name DevelopersChanges take effect for all members. When you attach a policy to Developers, every current member gets it. When you remove a user from the group, they lose what the group granted.
Why groups help
Without groups, you attach policies to each user one by one. When a team's needs change, you must update every user and risk missing one. With groups, you model jobs, not people. A new hire joins the group for their job, and a person who changes roles moves between groups.
A common pattern is to name groups by function, such as Developers, Billing, or Auditors. Keep each group's policy focused so that combining groups produces the access a person needs.
Effective permissions
A user's effective permissions come from the union of their own policies and the policies of all their groups. Any explicit Deny in any of them wins over every Allow. This means a user in Developers and Auditors gets both sets of allowed actions, unless a deny blocks one of them. A later chapter covers the full evaluation logic.
Limits and gotchas
- Groups cannot hold roles, so use groups only for IAM users. Workloads and federated people use roles instead.
- A group cannot be a principal in a resource-based policy. To grant a bucket policy to a team, you must name the users or an account, or use a role.
- Quotas apply, such as the number of groups per account and groups per user. Check the current IAM quotas page before designing a large layout.
- Deleting a group requires you to remove its members and detach its policies first. The console does this for you, while the CLI does not.
Exercise
Alice is in the Developers group, which allows s3:GetObject. She is also in the Auditors group, which has a policy that explicitly denies s3:GetObject on one bucket. Can Alice read objects from that bucket, and can you name the Developers group as the Principal in that bucket's policy?
Show answer
Alice cannot read objects from that bucket, because an explicit deny in any applicable policy overrides an allow. You cannot name a group as a Principal. Groups are not principals, so the policy must name users, a role, or an account.