Welcome to Day 3 of the 30 Days AWS Security Challenge. Yesterday we covered IAM users, groups, and policies. Today we tackle something that trips up a lot of people early on: the difference between an IAM user and an IAM role. They can look similar on the surface, but they solve very different problems, and mixing them up can leave your account harder to secure than it needs to be.
Quick Recap: What a User Is
An IAM user is a permanent identity tied to a specific person or application. It has its own long term credentials, either a password, access keys, or both. Once created, a user sticks around until someone deletes it, and its permissions stay attached unless you go in and change them.
Users are great for people who need ongoing, predictable access to AWS, like a developer who logs into the console every day.
What a Role Actually Is
A role is different in one key way: it has no permanent credentials attached to it. Instead of belonging to one specific person, a role is something that gets "assumed" temporarily. When something assumes a role, AWS hands out short lived, temporary credentials that expire automatically after a set period.
Think of a role less like an identity and more like a costume anyone eligible can put on for a while, use to do a job, then take back off. Once the session ends, those temporary credentials stop working entirely.
Why Temporary Credentials Matter
This might sound like a small technical detail, but it has a big security payoff. Long lived credentials, like the access keys tied to an IAM user, are a liability if they leak. Someone who steals them can use them indefinitely until you notice and manually revoke access.
Temporary credentials from a role expire on their own. Even if they somehow leak, the window for misuse is limited. This is a big part of why AWS and most security guidance push you toward roles wherever possible, instead of creating more IAM users with long lived keys.
Common Situations Where You Should Use a Role
Roles fit naturally in a few recurring scenarios:
- EC2 instances or Lambda functions that need AWS access. Instead of embedding access keys in your application code, attach a role to the instance or function. AWS handles rotating the temporary credentials automatically.
- Cross account access. If a user in Account A needs to access resources in Account B, you set up a role in Account B that Account A is allowed to assume, rather than creating a duplicate user.
- Federated access. If your company uses a corporate identity provider like Okta or Azure AD, users log in through that provider and assume a role in AWS, instead of getting individual IAM users created for them.
- Temporary elevated access. If someone occasionally needs admin level permissions for a specific task, a role they assume for that task is safer than giving them permanent admin access as a user.
When a User Still Makes Sense
Roles are not a full replacement for users. You still want IAM users for cases where a person needs direct, ongoing console access and your organization is not using a federated identity provider. Even then, best practice is to require MFA (which we cover tomorrow) and avoid generating long lived access keys unless there is a real programmatic need.
A simple way to check your own account: go to IAM > Users, and look at how many users have access keys attached that are old or unused. Those are candidates to either remove or replace with a role based approach.
Key Takeaways
- IAM users have permanent, long lived credentials tied to a specific person or app
- IAM roles have no permanent credentials, they are assumed temporarily and issue short lived credentials
- Roles are the safer default for EC2, Lambda, cross account access, and federated logins
- Temporary credentials limit the damage if something ever leaks
- Users still have a place, but should be paired with MFA and minimal standing access keys
Tomorrow we go inside an actual IAM policy and break down the JSON structure line by line, so those permission documents stop feeling like a wall of text.
Loading article