IAM user vs IAM role: long-term or temporary credentials?

An IAM user identifies a specific person or workload, can have a long-term password or access keys, and can also obtain temporary credentials through AWS STS; an IAM role has no long-term credentials of its own and is assumed to obtain temporary credentials. AWS recommends preferring temporary credentials wherever possible.

Compare by characteristic

CharacteristicIAM userIAM role
CredentialsLong-term password or access keysTemporary, issued through AWS STS when the role is assumed
Who uses itOne specific person or applicationAny trusted identity: EC2, Lambda, another account or a federated user
Risk if keys leakLong-term keys can be abused until revokedCredentials expire, limiting the blast radius

When to use which

Applications running on EC2 or Lambda should use a role instead of storing access keys on the machine. Cross-account access and federation also use roles. A role has two main parts: a trust policy defining who may assume it and a permission policy defining what it may do.

  • Attach a role to EC2 through an instance profile.
  • Apply least privilege to users and roles alike.

Check your understanding

When a scenario asks how an application on EC2 can get permissions without storing access keys, the answer is an IAM role through an instance profile. Do not write keys into User Data or source code.

References

Use AWS documentation to check current features and limits. Cloud Quest is an independent learning project and does not guarantee exam outcomes.

Continue learning

Learn AWS and prepare for SAA-C03

Read the guide →

A practical SAA-C03 study roadmap

Read the guide →

Free AWS SAA-C03 practice questions

Read the guide →

Practice AWS concepts with simulated labs

Read the guide →

AWS glossary

Explore services and concepts →

Put your understanding into practice

Sign in to learn, review and save progress. Tool access depends on account status.

Sign in to learn