
AWS IAM Explained Simply: Users, Groups, Roles and Policies (and the Mistakes Every Beginner Makes)
IAM is the front door of your AWS account, and most beginners skip it. In this post I explain the root user, IAM users, groups, roles and policies with a simple building-and-badges analogy, break down a real JSON policy, show how AWS decides between Allow and Deny, and share a checklist of the most common beginner mistakes, like hardcoded access keys and AdministratorAccess everywhere.
When I opened the AWS Console for the first time, I wanted to start building right away. Launch an EC2 instance, make a bucket, deploy something. IAM looked like paperwork that stood between me and the fun part.
That was a mistake. IAM (Identity and Access Management) is the front door of your AWS account. Whoever gets through it can do anything you allowed. That includes spinning up resources you'll pay for, deleting your data, or leaking it.
In this post I'll explain IAM the way I wish someone had explained it to me: no jargon dumps, just the mental model, a real policy example, and the mistakes I see beginners make all the time (including some I made myself).
The mental model: a building with badges
Think of your AWS account as an office building:
- The root user is the building's owner. They have the master key that opens every door, including the safe and the power room. You don't use the master key to grab a coffee.
- IAM users are employees with their own badges.
- IAM groups are departments. Instead of programming every badge one by one, you say "everyone in Finance can open the Finance floor."
- IAM roles are visitor badges. You pick one up at the front desk when you need it, it works for a limited time, and then it expires.
- IAM policies are the rules written on the badge: which doors it opens and which it doesn't.
Every IAM concept you'll meet fits somewhere in that picture.
1. The root user: lock it away
The root user is the email address and password you used to create the account. It has unrestricted access to everything, including billing and closing the account. You can't limit it with policies.
What to do:
- Turn on MFA (Multi-Factor Authentication) for root. AWS now requires MFA for root users on all account types, so if you haven't set it up yet you'll be asked to the next time you sign in. Passkeys and security keys work, and you can register more than one device as a backup.
- Don't create access keys for root. If you have them, delete them.
- Create a separate identity for daily work and only sign in as root for the few tasks that actually need it, like changing account settings or some billing tasks.
If you remember one thing from this post: the root user is for emergencies, not for Tuesday.
2. Users and groups: people who need access
An IAM user is a long-term identity for a person or an application. It can have:
- A console password (to log in to the web console)
- Access keys (an Access Key ID + Secret Access Key, used by the CLI, SDKs and scripts)
Groups are just collections of users. Groups don't log in. They exist so you attach permissions once instead of repeating them for every user.
Group: Developers → policy: read/write on the dev S3 bucketGroup: Auditors → policy: ReadOnlyAccessWhen a new dev joins, you add them to
Developers and they get the right permissions. When they leave, you remove them, and that's it.Side note for real teams: for human users in organizations, AWS recommends IAM Identity Center (formerly AWS SSO). People sign in with temporary credentials instead of long-lived IAM users. For a personal learning account, a single IAM user with MFA is a fine starting point. Just know Identity Center exists, because it shows up a lot in exams and in real jobs.
3. Roles: temporary access, the AWS way
This is where most beginners get confused, so let's slow down.
A role is an identity with permissions, but with no password and no permanent keys. Instead, someone (or something) assumes the role and gets temporary credentials that expire automatically. The service that hands out these credentials is AWS STS (Security Token Service).
Who assumes roles?
Who | Example |
|---|---|
An AWS service | An EC2 instance that needs to read files from S3 |
A Lambda function | A function that writes items to DynamoDB |
A user from another account | A consultant who needs access to your account for a week |
An external identity | Someone logging in through Google, GitHub Actions or a corporate login |
Every role has two parts:
- Trust policy: who is allowed to assume this role (for example, "the EC2 service")
- Permissions policy: what the role can do once assumed (for example, "read from bucket X")
Why roles matter so much
Here's the classic beginner mistake: you create an IAM user, generate access keys, and paste them into your EC2 instance or your code so it can talk to S3.
It works, until those keys end up in a GitHub repo, a screenshot, or a log file. Long-lived keys don't expire, so a leaked key stays a working key until someone notices.
The right way: attach a role to the EC2 instance (through an instance profile). The AWS SDK on the instance picks up temporary credentials automatically and rotates them for you. No keys in your code, nothing to leak.
Rule of thumb: if code running inside AWS needs permissions, give it a role, never access keys.
4. Policies: the actual rules
A policy is a JSON document that says what's allowed or denied. Here's a real one that lets someone only read files from one specific bucket:
json
{ "Version": "2012-10-17", "Statement": [ { "Sid": "ListTheBucket", "Effect": "Allow", "Action": "s3:ListBucket", "Resource": "arn:aws:s3:::my-portfolio-assets" }, { "Sid": "ReadObjects", "Effect": "Allow", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::my-portfolio-assets/*" } ]}Let's break it down:
-
Version: the policy language version. It's always"2012-10-17". It's not the date you wrote it, don't change it.
-
Effect:AlloworDeny.
-
Action: what API calls are covered, in the formatservice:Action(s3:GetObject,ec2:StartInstances...).
-
Resource: which resources, identified by their ARN (Amazon Resource Name), the unique ID of every resource in AWS.
-
Sid: an optional label so humans know what each statement is for.
Notice the two statements.
ListBucket applies to the bucket itself ( my-portfolio-assets ), while GetObject applies to the objects inside it ( my-portfolio-assets/* ). Mixing these up is one of the most common reasons a policy "doesn't work."Managed vs inline policies
- AWS managed policies: ready-made by AWS (like
ReadOnlyAccessorAmazonS3ReadOnlyAccess). Handy, but often broader than you need.
- Customer managed policies: policies you write and reuse across users, groups and roles.
- Inline policies: embedded directly into one identity. Use them rarely, they're harder to keep track of.
5. How AWS decides: allow or deny?
Every request to AWS is checked against the policies that apply. The logic boils down to three rules:
- By default, everything is denied. If nothing explicitly allows an action, the answer is no. This is called an implicit deny.
- An explicit
Allowopens the door, as long as nothing denies it.
- An explicit
Denyalways wins. It doesn't matter how many policies allow the action: oneDenyblocks it.
Is there an explicit Deny? → YES → ❌ Denied → NO → Is there an explicit Allow? → YES → ✅ Allowed → NO → ❌ Denied (implicit)Once this clicks, debugging "Access Denied" errors gets much easier. You stop guessing and start asking: "Which policy should be allowing this, and is anything denying it?"
6. Least privilege: the principle behind everything
Least privilege means giving an identity only the permissions it needs to do its job, and nothing more.
It's tempting to attach
AdministratorAccess to everything so the errors go away. But think about what happens if that identity gets compromised: the attacker gets admin too.A practical way to get there without going crazy:
- Start with a narrow policy (or a managed one that's close to what you need).
- When you hit an
AccessDenied, read the error. It usually tells you the exact action that was blocked.
- Add that specific action on that specific resource.
- Periodically check what isn't being used. IAM Access Analyzer and the "Last accessed" info in the IAM console show permissions and identities nobody touches anymore.
The beginner mistakes checklist
Before you build anything else, run through this list on your account:
- Root user has MFA enabled
- Root user has no access keys
- I use a separate identity (IAM user or Identity Center) for daily work, with MFA
- No access keys hardcoded in code,
.envfiles committed to Git, or screenshots
- EC2 instances and Lambda functions use roles, not access keys
- Permissions are attached to groups, not to individual users one by one
- Nothing has
AdministratorAccess"just to make it work"
- I delete users, keys and roles I'm no longer using
Wrapping up
IAM looks bureaucratic at first, but it's really a small set of ideas:
- Root is the master key: lock it away with MFA.
- Users and groups are for long-term identities, organized by function.
- Roles give temporary credentials, and they're the right answer for anything running inside AWS.
- Policies are JSON rules, where an explicit Deny always wins and everything starts denied.
- Least privilege keeps a small mistake from becoming a big incident.
IAM is also free and global (it's not tied to a Region), so there's no reason not to set it up properly from day one. It's also one of the topics that shows up most on the AWS Certified Cloud Practitioner exam, under the Security and Compliance domain and the Shared Responsibility Model: AWS secures the infrastructure, and you are responsible for who gets access to your account.
If this helped, check out the other posts in this series, where I cover VPCs, cost control and the core AWS services. And tell me in the comments: what was the first
AccessDenied error that made you lose an afternoon? 😅Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article