Controlling Access with IAM Users, Groups, Roles and Policies
This lesson explains how AWS Identity and Access Management (IAM) controls who can sign in to an AWS account, which is authentication, and what they can do there, which is authorisation. IAM is free and global.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish IAM users, groups and roles.
- Distinguish AWS managed, customer managed and inline policies.
- Explain the principle of least privilege and the tools that help apply it.
IAM identities
IAM has three kinds of identity. An IAM user represents a person or an application that uses AWS, and has long-term credentials: a password for the console, access keys for the command line and SDKs, or both. A group is a collection of users; permissions attached to the group apply to every member, which makes managing many users easier. A group has no credentials of its own, cannot sign in and cannot contain other groups.
A role is an identity with permissions that is assumed by someone or something that needs them, such as an EC2 instance that must read from S3, a user in another account, or a person signing in through a corporate directory. A role has no permanent credentials; assuming it provides temporary ones that expire, which is safer than storing access keys. The following table summarises the three identities.
| Identity | What it is | Credentials |
|---|---|---|
| User | A person or application that interacts with AWS | Long-term: a console password, access keys for CLI and SDKs, or both |
| Group | A collection of users; permissions attached once apply to all members. Cannot be nested or sign in | None |
| Role | An identity with permissions that is assumed; used by AWS services (e.g. EC2 reading S3), other accounts and federated users | Temporary, no permanent credentials |
The following diagram shows the three identities and how they get permissions.

User, group or role?
Policies
Permissions in IAM are defined by policies: JSON documents that list the actions allowed or denied on resources. There are three kinds. AWS managed policies are prebuilt and maintained by AWS, such as ReadOnlyAccess, and are a quick way to grant common sets of permissions. Customer managed policies are written by you and can be attached to many identities, which suits precise, least-privilege permissions. Inline policies are embedded in a single user, group or role and are deleted with it. The following table summarises the types.
| Policy type | Meaning |
|---|---|
| AWS managed | Prebuilt by AWS, such as ReadOnlyAccess |
| Customer managed | Created and reused by you |
| Inline | Embedded in a single user, group or role |
The following list describes the rules by which AWS evaluates them.
- By default everything is denied; an allow is needed for any action.
- An explicit deny overrides any allow.
How policies work
Least privilege
Grant only the permissions needed for the job. Review permissions regularly and remove unused ones; IAM Access Analyzer and last-accessed information help find unused or overly broad access.
Setting up access for a small team
A start-up has three developers, two finance staff and an application running on EC2 that reads files from S3. A well-designed setup uses each IAM feature for its purpose:
| Who | IAM setup |
|---|---|
| Developers | A Developers group with permissions for the services they build with |
| Finance staff | A Finance group with billing read access only |
| The EC2 application | An IAM role attached to the instance, allowing s3:GetObject on one bucket |
The application's permissions are a short JSON policy granting only what it needs (least privilege):
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::startup-invoices/*"
}]
}When a new developer joins, an administrator adds them to the group and they get the right permissions immediately. The application never stores access keys: the role provides temporary credentials automatically.
What is the principle of least privilege?
Show answer
Granting only the permissions needed to do a task, and nothing more.
Exam Tips
Remember for the exam
- Attach policies to groups to make permissions easier to manage.
- EC2 instances should access other AWS services through IAM roles, not stored access keys.
- Roles provide temporary credentials.
- Least privilege means granting only the permissions that are needed.
- An explicit deny overrides any allow.
- IAM is global and free.