AWS IAM Explained: Users, Roles, Policies, and Least Privilege
A beginner-friendly guide to AWS Identity and Access Management, explaining users, roles, policies, permissions, and the principle of least privilege through practical examples.
AWS IAM Explained: Users, Roles, Policies, and Least Privilege
When I started exploring AWS, Identity and Access Management (IAM) initially seemed like a collection of users, roles, and permissions.
But there is a much simpler question behind IAM:
Who can do what, on which AWS resource, and under what conditions?
Understanding that question makes IAM much easier to approach.
In this article, I'll break down the fundamental IAM concepts and show how they fit together.
What Is AWS IAM?
AWS Identity and Access Management (IAM) helps control access to AWS resources.
Imagine an AWS environment containing:
- Amazon S3 buckets
- EC2 instances
- DynamoDB tables
- Lambda functions
Not every person or application should automatically have access to all of these resources.
IAM allows us to define who or what can access them and what actions they are permitted to perform.
Authentication vs Authorization
Before going further, there are two important concepts to separate.
Authentication
Authentication answers:
"Who are you?"
For example, a person signing into AWS must prove their identity.
Authorization
Authorization answers:
"What are you allowed to do?"
A user might successfully authenticate but still not have permission to delete an S3 bucket.
IAM is heavily involved in controlling this authorization.
IAM Users
An IAM user represents an identity within an AWS account.
Historically, IAM users have been used for people or workloads requiring long-term AWS credentials.
However, AWS recommends that human users access AWS using federation and temporary credentials where possible rather than relying on long-term IAM user credentials.
This is an important distinction when learning IAM:
IAM users exist, but creating individual IAM users is not automatically the preferred approach for every human user.
IAM User Groups
Suppose an organization has several developers.
Instead of attaching the same permissions separately to every user, users can be organized into groups.
For example:
Developers
could receive permissions appropriate for development resources.
Another group:
Auditors
might receive read-only permissions.
Groups therefore make permission management easier when multiple IAM users require similar access.
IAM Roles
Roles are one of the most important IAM concepts.
Unlike an IAM user, a role is intended to be assumed by an authorized identity.
When the role is assumed, temporary security credentials are provided.
Roles are commonly used by:
- AWS services
- Applications
- Federated users
- Workloads
- Cross-account access
Let's look at an example.
Suppose we have:
Lambda → DynamoDB
Our Lambda function needs permission to write data to a DynamoDB table.
We shouldn't put permanent AWS credentials inside the application code.
Instead, we can assign the Lambda function an IAM role.
That role can contain the permissions required to access DynamoDB.
The architecture becomes:
API Gateway → Lambda
↓
**IAM Role**
↓
**DynamoDB**The Lambda function receives temporary credentials based on its execution role.
This is much safer than hardcoding long-term credentials into the application.
What Are IAM Policies?
Policies define permissions.
AWS IAM policies are commonly represented as JSON documents.
A simplified policy might look like this:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::example-bucket/*" } ]}Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article