AWS Builder Center

AWS IAM Explained: Users, Roles, and Policies

Every action in AWS, from launching a server to reading a file, goes through IAM (Identity and Access Management). It decides who can do what, and it’s the most common source of “Access Denied” errors. Once you understand its few building blocks, those errors become much easier to fix.

Exploring Things

The core pieces

  • Users: long-term identities for people or apps, with their own credentials.
  • Groups: collections of users that share the same permissions.
  • Roles: identities that anyone or anything can assume temporarily. Services like Lambda and EC2 use roles to get permissions without storing keys.
  • Policies: JSON documents that define what is allowed or denied.
Prefer roles over long-term access keys. A role hands out temporary credentials that expire, so there is nothing permanent to leak.

Anatomy of a policy

json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": "arn:aws:s3:::my-example-bucket/reports/*"
}
]
}
Each statement answers four questions:
  • Effect: Allow or Deny.
  • Action: which API calls are covered.
  • Resource: which specific resources they apply to.
  • Condition (optional): extra rules, such as requiring MFA or a certain IP range.

How AWS decides

The rules are simple:
  1. Everything is denied by default.
  1. An explicit Allow grants access.
  1. An explicit Deny always wins, even if something else allows the action.
When you see “Access Denied,” one of three things is usually true: nothing allows the action, a Deny is blocking it, or you’re granting it on the wrong resource.

Least privilege

Give each identity only the permissions it needs. A tempting shortcut is  "Action": "*"  on  "Resource": "*" , but that gives full access to everything. Start narrow, test, and widen only when something breaks. IAM Access Analyzer can help you spot overly broad access and generate tighter policies from real activity.

Quick wins

  • Turn on MFA for your root user and don’t use root for daily work.
  • Create separate roles per application instead of sharing one.
  • Review unused users and keys regularly and remove them.

Common mistakes

  • Hardcoding access keys in code or committing them to Git.
  • Using wildcards ( * ) for actions and resources “just to make it work.”
  • Forgetting that a Deny overrides every Allow.

Conclusion

IAM looks intimidating, but it comes down to who (users and roles), what (actions on resources), and the rule that deny beats allow. Use roles, keep permissions narrow, and protect your root account with MFA.
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