AWS Builder Center

IAM in Plain English: Users, Roles and Policies

A beginner-friendly explanation of IAM users, roles and policies, what least privilege actually means, and one example of a risky policy and a safer one.

What IAM does

AWS Identity and Access Management (IAM) answers one question: who is allowed to do what on which resources? Every request to AWS is checked against it. Understanding a handful of building blocks will make the rest of AWS much less confusing.

Users, roles and policies

An IAM user is an identity for a person or application with long-term credentials, such as a password or access keys. A role is an identity that nobody logs into directly. Instead, a user, an AWS service like EC2 or Lambda, or another account assumes the role and receives temporary credentials. This is why roles are generally safer: nothing long-lived is lying around to leak. A policy is a JSON document that lists what is allowed or denied, and you attach it to a user, group or role to give it permissions.

How a decision gets made

By default, everything is denied. A request only succeeds if a policy explicitly allows it, and an explicit deny always overrides any allow. If you're ever confused about why something fails, remember these two rules first.

Least privilege, with an example

Least privilege means giving only the permissions needed for the job. Here's a policy that looks convenient but is far too broad:
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}
It lets the identity do anything with every S3 bucket in the account, including deleting data. A safer version allows only reading objects from one bucket:
{
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-learning-bucket/*"
}
Start narrow and widen it only when something legitimately fails.

Habits worth building early

Don't use the root account for daily work. Lock it down with multi-factor authentication (MFA) and use it only for the few tasks that truly need it. Give each application a role instead of embedding access keys in code. Never commit access keys to GitHub, since leaked keys are one of the most common ways accounts get compromised. Review permissions regularly and remove what you no longer use.

Wrap-up

IAM looks intimidating, but it comes down to identities, permissions and a default of "deny". Once you can explain the difference between a user and a role, you're already ahead of many beginners. What was the first IAM error you ran into, and how did you fix it?
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article