AWS Builder Center

Implementing Least-Privilege Access with AWS IAM

Learn how to secure AWS resources using IAM users, roles, policies, and permission testing through a practical hands-on exercise.

IT Student | Full-Stack Developer | AI/ML & Cloud Enthusiast
Security is one of the most important aspects of cloud computing. Every user and application should have access only to the resources required to perform its tasks.
AWS Identity and Access Management (IAM) helps organizations manage identities, permissions, and access to cloud resources.

Five important IAM concepts

  1. IAM Users: Represent identities that need access to AWS resources.
  1. IAM Groups: Organize users and assign common permissions.
  1. IAM Roles: Provide temporary credentials to trusted users and AWS services.
  1. IAM Policies: Define which actions are allowed or denied on specific resources.
  1. Least Privilege: Grant only the minimum permissions required.

Hands-on AWS Example: Create a Read-Only S3 Access Policy

Objective: Create an IAM user that can view S3 buckets and objects but cannot upload or delete files.
Step 1: Create an S3 bucket
  • Open the AWS Management Console.
  • Navigate to Amazon S3.
  • Create a test bucket and upload a sample file.
  • Keep Block Public Access enabled.
Step 2: Create an IAM policy
Navigate to IAM → Policies → Create policy → JSON and use:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:ListBucket",
"s3:GetObject"
],
"Resource": [
"*"
]
}
]
}
For a production environment, restrict the resources to the specific bucket and its objects rather than using wildcards.
Step 3: Create an IAM user
  • Navigate to IAM → Users.
  • Create a test user.
  • Attach the read-only policy created earlier.
  • Use a separate test account or session to verify the permissions.
Step 4: Test the permissions
Try these operations:
Action
Expected result
View S3 buckets
Allowed
View objects
Allowed
Download an object
Allowed
Upload a new object
Denied
Delete an object
Denied
Step 5: Review access
  • Use IAM policy details to inspect granted permissions.
  • Check CloudTrail event history for recorded API activity.

What You Learn

This exercise demonstrates IAM policy creation, permission boundaries at the resource level, access testing, and the principle of least privilege.
Important: Perform this exercise in a controlled test environment. Avoid creating long-term access keys, never use root credentials for routine work, and delete test identities when finished.
Strong cloud security begins with understanding who can access what—and why.
What AWS security concept would you like to explore next: IAM roles, MFA, or policy evaluation?
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article