← Back to Home
πŸ”

AWS IAM β€” Users, Roles & Permissions

Who can do what, to which resources β€” the control system behind every secure AWS account.

⏱12 min readπŸ“šDevOps Fundamentals

IAM (Identity and Access Management) is how AWS decides who is allowed to do what. Get IAM right and your account is secure; get it wrong and you’ve handed the keys to attackers. It’s free, and it’s the first thing to master in any cloud.


🎯 Learning Objectives

By the end of this lesson you will:


The Four IAM Building Blocks

Concept What it is
User A person or app with long-term credentials
Group A collection of users sharing permissions (e.g. Developers)
Policy A JSON document that grants or denies specific actions
Role A set of permissions that can be assumed temporarily β€” by a user, service, or EC2 instance

Policies: the Rules Themselves

A policy is JSON that says which actions are allowed on which resources:

json
{
"Version": "2012-10-17",
"Statement": [{
  "Effect": "Allow",
  "Action": ["s3:GetObject", "s3:ListBucket"],
  "Resource": "arn:aws:s3:::my-app-bucket/*"
}]
}

This policy allows reading objects from one specific bucket β€” and nothing else.

πŸ’‘ Principle of Least Privilege

Grant only the permissions actually needed to do the job β€” no more. Start with nothing and add access as required, rather than granting broad access and hoping to lock it down later.


Roles Beat Long-Lived Keys

A common mistake is storing an access key on a server. Instead, attach an IAM role to the EC2 instance β€” AWS then hands it short-lived, auto-rotating credentials.

⚠ Never do this

Never hard-code AWS access keys in your code, commit them to Git, or bake them into an EC2 instance. Leaked keys are one of the most common causes of cloud breaches. Use roles for services and short-lived credentials for humans.


Configure the AWS CLI

bash
aws configure
# AWS Access Key ID:     ****************
# AWS Secret Access Key: ****************
# Default region name:   eu-west-1
# Default output format: json
bash β€” 80Γ—24
student@devops:~$aws sts get-caller-identity

aws sts get-caller-identity is the β€œwhoami” of AWS β€” it confirms which identity your CLI is using.


πŸ§ͺ Hands-on Lab

πŸ“

Create a Least-Privilege User

In the AWS Console:

  1. Enable MFA on your root account (then stop using root for daily work).
  2. Create an IAM group called Developers.
  3. Attach a policy that grants only what’s needed (e.g. read-only S3).
  4. Create a user, add them to the group, and test with the CLI.

🧠 Knowledge Check

Knowledge Check

What is the principle of least privilege?

Knowledge Check

How should an EC2 instance access an S3 bucket securely?


πŸ’Ό Interview Preparation

Interview Q&A

Why are IAM roles preferred over IAM user access keys for applications?


Summary

You now understand IAM users, groups, roles, and policies, the principle of least privilege, and why roles beat static keys. Next, you’ll launch your first virtual server with EC2.

Up Next

AWS EC2 β€” Virtual Servers

You've mastered this lesson. Continue your journey to becoming a DevOps Engineer.

Start Next Lesson→