Skip to Content

Users, groups and policies

IAM users and groups, how JSON policies give them permissions, and the principle of least privilege.

What it is

An IAM user is an identity for one person (or, rarely, one application) in an AWS account. An IAM group is a set of users who need the same permissions. An IAM policy is a JSON document that lists what's allowed or denied.

Together they solve a simple problem: everyone who uses the account needs their own sign-in, and the right access has to reach the right people without much effort.

How it works

IAM users in the Developers, Operations and Audit Team groups, with Fred in no group IAM users in the Developers, Operations and Audit Team groups, with Fred in no group

Users, groups and where their permissions come from.

One AWS account holds six users and three groups:

  • Alice and Bob are in Developers, so they get the Developers group's policies.
  • Charles is in Developers and Audit Team. He gets the policies of both groups.
  • David is in Operations and Audit Team, so he also gets both sets.
  • Edward is only in Operations.
  • Fred is in no group. His permissions come from an inline policy attached directly to his user.

The rules behind the picture:

  • A user can be in no group, one group or several groups. Permissions from every group add up.
  • A group contains only users. Groups can't contain other groups.
  • A policy can be attached to a user, a group or a role. Attaching to groups is easier to manage than attaching to each user.
  • IAM is global: users, groups and policies exist once for the whole account, not per Region.

Policies

A policy is a JSON document. This one lets its holder read and write objects in one S3 bucket:

S3 read and write policy
{
  "Version": "2012-10-17",
  "Id": "S3-Account-Permissions",
  "Statement": [
    {
      "Sid": "AllowReadWriteOnMyBucket",
      "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:PutObject"],
      "Resource": ["arn:aws:s3:::my-bucket/*"]
    }
  ]
}

The parts of a policy

  • Version: the policy language version. Always use "2012-10-17".
  • Id (optional): a name for the policy.
  • Statement: one or more statements. Each statement has:
    • Sid (optional): a name for the statement.
    • Effect: Allow or Deny.
    • Principal: who the statement applies to. Used only in resource-based policies (such as an S3 bucket policy), because an identity policy already applies to whoever it's attached to.
    • Action: the API actions, such as s3:GetObject or ec2:*.
    • Resource: what the actions apply to, written as ARNs.
    • Condition (optional): when the statement applies, for example only from one IP range. See conditions.

An ARN (Amazon Resource Name) is the unique name of a resource: arn:aws:s3:::my-bucket is a bucket, arn:aws:s3:::my-bucket/* is every object in it, and arn:aws:iam::123456789012:user/alice is a user. * is a wildcard: "Action": "ec2:Describe*" matches every EC2 action that starts with Describe.

Kinds of policies

  • AWS managed policies are written and updated by AWS for common jobs, such as AdministratorAccess, ReadOnlyAccess or AmazonS3ReadOnlyAccess. Quick to use, but often broader than needed.
  • Customer managed policies are ones the customer writes. One can be attached to many users, groups and roles, and change it in one place.
  • Inline policies are written inside one user, group or role and deleted with it. Use them only for a strict one-to-one link.

Least privilege

The principle of least privilege means giving each identity only the permissions it needs for its job, and nothing more. If its credentials leak, the damage is limited to what it could do.

In practice: start from an AWS managed policy to get going, then replace it with a customer managed policy that lists only the actions and resources really used. IAM Access Analyzer can generate such a policy from the activity in CloudTrail.

Limits

ItemDefaultCan be raised to
Groups per account300500
Customer managed policies per account1,50010,000
Managed policies per user1020
Managed policies per group1010
Size of one managed policy6,144 charactersfixed

Real-world examples

  • A start-up creates an Admins group with AdministratorAccess for its two founders, and a Developers group with a custom policy for everyone else. New hires are added to Developers on day one.
  • An auditor is given a user in an Audit group with SecurityAudit and ReadOnlyAccess. They can see everything and change nothing.

Exam tips

  • "Give a team the same permissions" → put the users in a group and attach the policy to the group.
  • "Least privilege" → a customer managed policy with only the needed actions and resources.
  • "Policy attached directly to one user and deleted with it" → inline policy.
  • "Can a group contain another group?" → no.
  • "Principal" in a policy → it's a resource-based policy (for example a bucket policy), not an identity policy.

Exam tip

Be ready to read a short policy and say what it allows. Check the Effect, the Action list and the Resource ARN. A bucket ARN (arn:aws:s3:::my-bucket) and an object ARN (arn:aws:s3:::my-bucket/*) are different resources.

Common traps

  • "Attach AdministratorAccess so the developer isn't blocked." It breaks least privilege. Give the specific permissions instead.
  • Thinking IAM users are per Region. IAM is global.
  • Sharing one IAM user between people. One person, one user, so every action is traceable to someone.

Hands-on lab: create an admin user and group

Goal: stop using the root user. Create an Admins group, a personal IAM user in it, and sign in as that user.

Free

IAM has no charge.

Before you start: sign in as the root user (the email you signed up with). This is one of the few times you should.

Create the group

Open IAM → User groups → Create group. Name it Admins and attach the AWS managed policy AdministratorAccess. Choose Create user group.

Create your user

Open IAM → Users → Create user. Name it after yourself, for example alex. Tick Provide user access to the AWS Management Console, choose I want to create an IAM user, set a custom password and untick must create a new password at next sign-in.

Add the user to the group

On the permissions step choose Add user to group, tick Admins, then create the user. Open the user and check that the Permissions tab shows AdministratorAccess attached via group Admins.

Set an account alias

On the IAM dashboard, under AWS Account, choose Create next to Account alias and enter something unique, such as alex-saa-lab. Your sign-in URL becomes https://alex-saa-lab.signin.aws.amazon.com/console.

Sign in as the new user

Open the sign-in URL in a private browser window and sign in as alex. The top-right corner now shows alex @ alex-saa-lab.

Expected result: you can do everything in the console as your IAM user. Use it for every later lab, and add MFA to it in the next lab.

Clean up: keep this user and group for the rest of the course.

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt