IAM Least Privilege Explained: Designing Secure Access the DevOps Way (Project 3)

When learning AWS IAM, many people believe that security means adding more permissions.
In real DevOps, security means the opposite:
Give only what is required. Nothing more.
This project focuses on implementing the Principle of Least Privilege in the simplest and cleanest possible way—without confusion, without over-engineering.
This is Project 3 of my AWS DevOps journey.
What Is Least Privilege?
The Principle of Least Privilege means:
Grant only required permissions
For only required resources
For only required actions
Anything extra increases:
Security risk
Blast radius during attacks
Chances of accidental data loss
In DevOps, over-permission is a vulnerability.
The Real Problem with Managed IAM Policies
AWS provides managed policies like:
AmazonS3ReadOnlyAccessAmazonS3FullAccess
These policies are:
Easy to use
Helpful for beginners
❌ Too broad for production
For example, AmazonS3ReadOnlyAccess allows reading all S3 buckets, not just one.
In real environments, this is unnecessary and risky.
Project Scenario (Simple & Realistic)
Requirement
An EC2 instance should be able to:
✅ Read objects from one specific S3 bucket
❌ Not list all buckets
❌ Not delete objects
❌ Not upload objects
❌ Not access any other bucket
This is a very common real-world DevOps requirement.
Architecture Used
EC2 Instance
|
| (Assumes IAM Role)
v
IAM Role (Least Privilege Policy)
|
v
Amazon S3 (Single Bucket Only)
Key points:
No IAM users
No access keys
Only IAM Role–based access
Step 1: Creating a Controlled S3 Resource
A dedicated S3 bucket was created:
devops-least-privilege-demo
A test file was uploaded:
test.txt
This bucket is the only resource the EC2 instance should access.
Step 2: Designing a Minimal IAM Policy
Instead of using AWS managed policies, a custom IAM policy was written.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowReadObjectsOnly",
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::devops-least-privilege-demo/*"
}
]
}
Why this policy is correct
Allows only read access
Restricted to one bucket
No delete, no write, no list permissions
Simple and predictable behavior
This is true least privilege.
Step 3: Using IAM Role with EC2
The policy was attached to an IAM Role, which was then assigned to the EC2 instance.
Important:
No
aws configureNo access keys
No IAM users
AWS automatically provides temporary credentials to the EC2 instance.
Step 4: Validation (Most Important Part)
Allowed action (worked as expected)
aws s3 cp s3://devops-least-privilege-demo/test.txt .
The file downloaded successfully.
Forbidden actions (failed as expected)
aws s3 rm s3://devops-least-privilege-demo/test.txt
aws s3 ls
Both commands returned AccessDenied.
This confirms that:
The policy is enforced
Over-permission does not exist
Security boundaries are correct
Why This Approach Matters in DevOps
In real production systems:
Servers get compromised
Credentials get leaked
Mistakes happen
Least privilege ensures:
Minimal damage during incidents
Better security posture
Easier audits and compliance
Security is not about complexity—it’s about intentional minimalism.
Key Learnings from This Project
Least privilege should start simple
IAM Roles are mandatory for EC2
Object-level permissions are easier to control
Validation is more important than assumptions
Clean design is better than clever design
Interview-Ready Explanation
“I implemented a least-privilege IAM policy that allowed an EC2 instance to read objects from only one S3 bucket using an IAM Role, while denying all other actions.”
This clearly shows security awareness and real hands-on experience.
Documentation
Complete step-by-step documentation is available on GitHub:
👉 LINK
Final Thoughts
Least privilege is not an AWS feature.
It is a DevOps mindset.
If you can design minimal, secure permissions and validate them correctly, you are no longer just learning AWS you are engineering secure cloud systems.
What’s Next
Project 4 – IAM Policy Conditions (Time-based and IP-based access control)


