IAM: Users, Groups, Roles and Policies
Overview
AWS Identity and Access Management (IAM) controls who (authentication) can do what (authorization) on which resources in your AWS account. It is a global, free service and the foundation of AWS security.
Imagine an office building with a security desk. Each employee gets a badge (an IAM user or role), badges are grouped by department (IAM groups), and a rulebook (IAM policies) says which rooms each badge can enter. The building owner (the root user) has a master key that should be locked away and almost never used.
IAM is covered in nearly every Cloud Practitioner exam. Know the building blocks, the principle of least privilege, and why MFA matters.
Key Concepts
- The root user is created with the account, has unrestricted access, and should be protected with MFA and used only for a few account-level tasks.
- An IAM user represents a person or application with long-term credentials (password and/or access keys).
- An IAM group is a collection of users; attach policies to the group to manage permissions at scale. Groups cannot contain other groups.
- An IAM role provides temporary credentials and is assumed by users, applications or AWS services (for example an EC2 instance role).
- An IAM policy is a JSON document that allows or denies actions on resources; an explicit Deny always wins.
- Least privilege: grant only the permissions needed for a task, and nothing more.
- MFA adds a second factor (virtual app, FIDO2 security key or hardware token) to protect sign-in.
- IAM Identity Center provides single sign-on (SSO) to multiple accounts and applications using workforce identities.
Detailed Notes
Core identity types
| Entity | Purpose | Credentials |
|---|---|---|
| Root user | Owner of the account | Email + password (+ MFA) |
| IAM user | One person or application | Password, access keys (long-term) |
| IAM group | Permission management for users | None (not an identity itself) |
| IAM role | Temporary access for users, services, other accounts | Temporary STS credentials |
Policy anatomy
IAM policies are JSON documents with Effect, Action, Resource and optional Condition.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:ListBucket"],
"Resource": [
"arn:aws:s3:::reports-bucket",
"arn:aws:s3:::reports-bucket/*"
]
}]
}
Policy evaluation in plain words
- By default, everything is denied.
- An explicit Allow in an attached policy permits the action.
- An explicit Deny anywhere overrides any Allow.
Policy types
| Type | Attached to | Notes |
|---|---|---|
| AWS managed policy | Users, groups, roles | Created and maintained by AWS (for example ReadOnlyAccess) |
| Customer managed policy | Users, groups, roles | You write and version it |
| Inline policy | A single user, group or role | Embedded one-to-one; harder to reuse |
| Resource-based policy | A resource such as an S3 bucket | Names a principal, enables cross-account access |
Roles in practice
A role has no password. An EC2 instance, Lambda function or another account assumes the role and receives temporary credentials via the AWS Security Token Service (STS). This avoids storing access keys in code.
# Show who you are
aws sts get-caller-identity
# Create a user and enable MFA from the console, then attach a managed policy
aws iam create-user --user-name analyst
aws iam attach-user-policy --user-name analyst \
--policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess
Strong authentication practices
| Practice | Why |
|---|---|
| MFA on root and all human users | Stops stolen-password attacks |
| Password policy | Enforces length, complexity and rotation rules |
| No root access keys | Root keys are extremely powerful |
| Rotate and remove unused access keys | Reduces exposure |
| Use roles instead of long-term keys | Credentials expire automatically |
Tools that help
- IAM Credential Report: CSV of all users and credential status.
- IAM Access Advisor: shows which services a user last accessed to trim permissions.
- IAM Access Analyzer: finds resources shared externally and helps generate least-privilege policies.
- IAM Identity Center: central SSO and permission sets across accounts, replacing many individual IAM users for workforce access.
- Amazon Cognito: sign-up and sign-in for application customers, separate from workforce IAM.
Real World Example
A data-analytics team needs read access to reports in S3. Instead of sharing the account password, the admin creates an IAM group called Analysts with a policy allowing only s3:GetObject on the reports bucket, and adds each analyst with MFA enforced.
The reporting application on EC2 uses an IAM role instead of embedded access keys. Quarterly, the team reviews Access Advisor and removes permissions no one has used.
Architecture Diagram
- 1Create users and put them in groups that match job functions.
- 2Attach policies to groups to allow only needed actions.
- 3Give applications and AWS services roles instead of long-term keys.
- 4Review usage with Access Advisor and tighten permissions regularly.
Best Practices
- ✓Lock away the root user: enable MFA, delete its access keys and do not use it day to day.
- ✓Apply least privilege and start from read-only, adding permissions as needed.
- ✓Manage human access with groups or IAM Identity Center, not per-user policies.
- ✓Use roles for applications and AWS services rather than embedding access keys.
- ✓Enable MFA for every human user and review credentials with the credential report.
Common Interview Questions
Exam Tips
CLF-C02 focus
- "Grant only the permissions required" = least privilege.
- "Application on EC2 needs to access S3" = IAM role, not access keys.
- IAM is global and free.
- The first task on a new account: enable MFA on the root user.
Finished this lesson?
0 of 43 lessons done · 0% of the course

