Lab Overview
AWS Identity and Access Management (IAM) is the security foundation of every AWS account. This lab teaches you to create users, organize them into groups, write custom JSON policies using the principle of least privilege, configure service roles, and test permissions by logging in as a restricted user.
IAM is always free and has the highest exam weighting of any domain on the Cloud Practitioner exam.
| Service | Purpose | Free Tier |
|---|---|---|
| AWS IAM | Users, groups, roles, and policies for access control | Always free |
| AWS Console | Sign in as restricted user to verify permissions | Always free |
Step-by-Step Instructions
1
AWS IAM
Create IAM Users
- Search for
IAMand click it - Left sidebar → Users → Create user
- User name:
dev-user - Check Provide user access to the AWS Management Console
- Select I want to create an IAM user
- Console password: Custom password → enter a password
- Uncheck “Users must create a new password at next sign-in”
- Click Next → skip permissions for now → Create user
- Repeat to create a second user:
readonly-user
2
AWS IAM
Create IAM Groups and Assign Users
- Left sidebar → User groups → Create group
- Group name:
Developers - Add user:
dev-user - Click Create group
- Create a second group:
ReadOnly→ addreadonly-user
3
AWS IAM
Create a Custom Least-Privilege Policy
Instead of using broad managed policies, you will write a JSON policy that grants only the exact permissions needed.
- Left sidebar → Policies → Create policy
- Click JSON tab and paste the policy below
- Click Next → Policy name:
S3ReadOnlyAccess-Custom→ Create policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::*",
"arn:aws:s3:::*/*"
]
}
]
}4
AWS IAM
Attach Policies to Groups
- Left sidebar → User groups → click Developers
- Permissions tab → Add permissions → Attach policies
- Search for
AmazonEC2FullAccess→ attach it - Also attach
AmazonS3FullAccess - Click ReadOnly group → attach
S3ReadOnlyAccess-Custom
5
AWS IAM
Create a Service Role
- Left sidebar → Roles → Create role
- Trusted entity: AWS service → Use case: EC2 → Next
- Attach policy:
AmazonS3ReadOnlyAccess - Role name:
EC2-S3-ReadOnly-Role→ Create role
6
AWS Console
Test Permissions as the Restricted User
- Go to IAM → Users → readonly-user
- Copy the Console sign-in URL
- Open a private/incognito browser window and paste the URL
- Sign in with username
readonly-userand the password you set - Try to navigate to EC2 — you should see “You are not authorized”
- Try to navigate to S3 — you should be able to list buckets (read-only)
- Try to create an S3 bucket — should fail with an access denied error
- Close the incognito window and sign back in with your admin account
TIP: Always test permissions by signing in as the restricted user. Policy documents don't always behave as expected until you verify them.
Verification Checklist
- Users dev-user and readonly-user created with console access
- Groups Developers and ReadOnly created
- dev-user added to Developers group, readonly-user added to ReadOnly group
- Custom policy S3ReadOnlyAccess-Custom created with JSON
- Developers group has EC2FullAccess and S3FullAccess
- ReadOnly group has S3ReadOnlyAccess-Custom
- Service role EC2-S3-ReadOnly-Role created for EC2 trusted entity
- Signed in as readonly-user and verified EC2 access is denied
- Signed in as readonly-user and verified S3 read works but create is denied
What You Learned
- IAM Users — individual identities with credentials for console and API access
- IAM Groups — collections of users that share the same permissions
- IAM Policies — JSON documents defining Allow/Deny rules for AWS actions and resources
- Least privilege — granting only the minimum permissions required for a task
- Service roles — IAM roles that AWS services (like EC2) assume to access other services
- Policy testing — verifying permissions by signing in as a restricted user
Lab Cleanup
IMPORTANT: Delete all resources when finished.
| # | Resource | How to Delete |
|---|---|---|
| 1 | IAM Users | IAM → Users → select dev-user and readonly-user → Delete |
| 2 | IAM Groups | IAM → User groups → Developers and ReadOnly → Delete |
| 3 | IAM Policy | IAM → Policies → S3ReadOnlyAccess-Custom → Delete |
| 4 | IAM Role | IAM → Roles → EC2-S3-ReadOnly-Role → Delete |