Skip to content
EgyKode
03 · AWS by handLab 14 / 59
Guided labaws

AWS IAM & Least Privilege

Write a policy that grants exactly one action, prove what it blocks, and swap a long-lived key for a role.

Time
50 min
Level
Beginner
Objectives
4 objectives
Cost
Free

Where this fits in the platform

Before you start

You will need

  • AWS CLI v2, configured
  • An AWS account

You will be able to

  • Read and write an IAM policy document
  • Test a permission before shipping it, with the policy simulator
  • Explain the difference between a trust policy and a permissions policy

CostFree

— IAM users, roles and policies cost nothing.

How to clean up

The scenario#

The application has an access key with AdministratorAccess because that made it work. Everybody knows it is wrong; nobody knows what it actually needs.

This lab replaces it with a policy you can defend, and a role instead of a key.

The Terraform labs build IAM as code. This one works in the CLI and console deliberately — when a permission fails at 3am you will be reading the console, and a resource you have only ever seen through HCL is one you cannot debug.

Hands-on environment

Run it on AWS

This lab builds real cloud infrastructure, so it needs your own AWS account. Follow the cost and cleanup notes above — the resources are yours, and so is the bill.

Anything you tick here is your own record. EgyKode cannot see inside that terminal, so the success criteria stay self-assessed even when the environment checks your work for you.

The anatomy of a policy

Step 1 of 6

Clean up#

Run this even if you did not finish.

DestructiveThis removes real resources. Check which environment you are in first.

Terminal
aws iam detach-user-policy --user-name lab-reader --policy-arn <arn>
aws iam delete-policy --policy-arn <arn>
aws iam delete-user --user-name lab-reader
aws iam delete-role --role-name lab-reader-role

Cost of this lab: Free — IAM users, roles and policies cost nothing.

Success criteria

0 of 4

The concept behind it

Ready to try it without help?Do the challenge

Next up

Lab 14 of 59 on the project path

AWS VPC Networking by HandBuild the network by hand so the Terraform version stops being magic — and find out what actually makes a subnet public.55 minBeginner

Previous: HTTP & TLS Troubleshooting