IAM users, groups, roles and policies

Beginner · 19 min

Principals and permissions on AWS: when to use a user or a role, how groups and policy types attach, and why long-lived access keys are a last resort.

Before thisCreating an account and securing the root userRegions, endpoints, ARNs and service scope

Tiny Technical Tutorials · 19 min

IAM users, groups, roles and policies

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by Tiny Technical TutorialsReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • IAM answers one question for every API call: may this principal do this action on this resource, under these conditions.
  • A new identity can do nothing. Permissions come only from policies that allow them.
  • A user has long-lived credentials. A role has none of its own: it is assumed, and hands out temporary credentials. Prefer roles.
  • A group is only a way to attach policies to many users. It is not a principal and cannot sign a request or be named in a resource policy.
  • A role has two policies: a trust policy saying who may assume it and permissions policies saying what it can then do.
  • Customer managed policies are reusable and versioned, so prefer them to inline policies except where a strict one-to-one tie is wanted.

The question behind every call

Every request to AWS arrives signed by somebody. Before the service does anything, AWS asks: may this principal perform this action on this resource, under these circumstances? IAM, Identity and Access Management, is where you write the answers.

The starting answer is always no. A brand-new identity can sign requests and every one is refused. You add permissions; you never start with everything and take away. The general idea is least privilege. Here is the AWS machinery for it.

Who can ask

  • IAM user. A named identity with long-lived credentials: a console password, up to two access keys, or both.
  • IAM role. An identity with permissions but no password or keys. A trusted principal assumes it and receives temporary credentials that expire.
  • Groups are not on this list. A group is a bundle of users used to attach policies. It cannot sign anything.
  • The root user sits outside all this.

The difference between user and role is like a staff badge versus a visitor’s pass at a front desk. The badge is yours until someone remembers to cancel it. The pass is issued on request and stops working tonight.

So the modern default is: people sign in through Identity Center and get role credentials, and software uses roles. IAM users are for the cases where neither works, and each access key should be justified.

What permissions look like

A policy is a JSON document listing what is allowed or denied:

{"Version":"2012-10-17","Statement":[
 {"Effect":"Allow","Action":["dynamodb:GetItem","dynamodb:Query"],
  "Resource":"arn:aws:dynamodb:eu-west-1:123456789012:table/orders"},
 {"Effect":"Allow","Action":"dynamodb:ListTables","Resource":"*"}]}

It allows reading one table and listing table names. Where a policy sits determines its job:

Type Attached to Says
Identity-based user, group, role what this identity may do
Resource-based a bucket, queue, key, and so on who may use this resource
Role trust policy a role who may assume it
Guardrails (boundaries, SCPs, RCPs, session policies) various the most that can be allowed

Identity policies come in three forms. AWS managed policies are written by AWS, convenient and usually broader than you need. Customer managed policies are yours, reusable and versioned. Inline policies are embedded in one identity and die with it.

Wiring it up

aws iam create-policy --policy-name read-orders --policy-document file://read-orders.json
aws iam create-group --group-name developers
aws iam create-user --user-name ana
aws iam add-user-to-group --group-name developers --user-name ana
aws iam attach-group-policy --group-name developers --policy-arn arn:aws:iam::123456789012:policy/read-orders

The same managed policy can also go on a role. A role needs a second document first, its trust policy:

{"Version":"2012-10-17","Statement":[{"Effect":"Allow",
 "Principal":{"Service":"lambda.amazonaws.com"},"Action":"sts:AssumeRole"}]}
aws iam create-role --role-name orders-reader --assume-role-policy-document file://trust.json
aws iam attach-role-policy --role-name orders-reader --policy-arn arn:aws:iam::123456789012:policy/read-orders

The trust policy answers “who may wear this”, the attached policy answers “what can the wearer do”. Both are needed, and confusing them is the most common IAM mistake.

Now inspect the result:

$ aws iam list-attached-user-policies --user-name ana
{ "AttachedPolicies": [] }

$ aws iam list-entities-for-policy --policy-arn arn:aws:iam::123456789012:policy/read-orders
{ "Groups": ["developers"], "Roles": ["orders-reader"] }

Ana can read the table, yet her direct policy list is empty, because the permission arrives through the group. An audit that only checks users misses this.

Limits that shape designs

Quotas push you toward fewer, well-designed policies. By default a managed policy holds at most 6,144 characters (spaces not counted), a role accepts 20 managed policies and a user 10, and a role trust policy holds 2,048 characters. Some can be raised.

Changes are also eventually consistent. A new role or policy can take a little while to be honoured everywhere.

Habits

  • No access keys for root; as few as possible for anyone.
  • MFA on every human sign-in.
  • One role per workload, named for its job.
  • Review what is unused. IAM records when roles and keys were last used, and IAM Access Analyzer reports external and unused access.

About the video

The embed is Tiny Technical Tutorials’ updated “IAM Basics”, December 2024, 19 minutes. Its chapters cover why IAM exists, creating users and groups, why roles exist, permissions policies, attaching them, and creating a role, using slides and the console. It shows IAM users as the way to sign in; for people in a real organization prefer Identity Center. I judged it from chapters and description, since transcripts couldn’t be fetched. The re:Inforce talk in deeper builds the model from first principles.

What was run: the commands and outputs ran against moto, a local emulator. moto does not enforce permissions by default and its enforcement is not AWS’s, so nothing here demonstrates an allow or a deny. Quotas and identity rules are from AWS documentation, checked in November 2026.

Where this fits

You have seen a policy. Next, the full grammar and how several of them combine: policy documents and evaluation logic.

Check yourself

  1. 01You want ten developers to have the same permissions. What do you attach, and to what, if they are IAM users?

    Put the users in a group and attach a customer managed policy to the group. Changing the policy then changes all ten at once. In an organization, Identity Center groups and permission sets are better still.

  2. 02A role has an administrator permissions policy and a trust policy naming only the Lambda service. Can your colleague assume it?

    No. The trust policy decides who may assume the role. Your colleague is not listed, whatever the permissions say. A Lambda function configured with the role can.

  3. 03Why is an access key for a CI server a poor choice?

    It is a long-lived secret stored outside AWS that keeps working if it leaks. The CI system can exchange its own identity token for temporary role credentials instead.

  4. 04You attach a policy to a group, then list the attached policies of a member and get an empty list. Is the permission missing?

    No. The list shows only policies attached directly to the user. Permissions inherited through groups appear when you list the user's groups and their policies.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark