DEV Community

irfan pasha
irfan pasha

Posted on

πŸš€ Hosting a Static Portfolio Website on AWS S3 using IAM (Beginner Project)

As part of my AWS learning journey, I built and deployed a static portfolio website using Amazon S3 and secured access using IAM best practices.
This project helped me understand S3 static hosting, bucket policies, IAM permissions, and real-world troubleshooting.

In this article, I’ll walk you through every step I followed, from scratch to a working live website.

🧠 What You Will Learn

What static website hosting is

How to host a website using Amazon S3

How IAM permissions affect S3 access

How to troubleshoot Access Denied errors

How to apply least-privilege IAM access

πŸ› οΈ Technologies Used

Amazon S3

AWS IAM

HTML & CSS

Git & GitHub

AWS Console

πŸ“ Project Overview

The goal was to host a simple portfolio website containing:

Profile section

About me

Project details

The site is publicly accessible using an S3 static website endpoint.

🧱 Step 1: Create an S3 Bucket

Go to AWS Console β†’ S3

Click Create bucket

Provide:

Bucket name (must be globally unique)

Region (I used us-east-1)

Uncheck Block all public access

Acknowledge the warning

Click Create bucket

🌐 Step 2: Enable Static Website Hosting

Open the bucket

Go to Properties

Scroll to Static website hosting

Enable it

Set:

Index document: index.html

Save changes

You will get a website endpoint URL β€” keep this.

πŸ“„ Step 3: Upload Website Files

I created a simple index.html file containing HTML and CSS for my portfolio.

Folder structure:

aws-s3-static-portfolio/
│── index.html
│── assets/
β”‚ └── profile.png

Upload all files to the S3 bucket.

πŸ” Step 4: Fix Access Denied (Bucket Policy)

Initially, I got this error:

AccessDenied

To fix this, I added a bucket policy to allow public read access.

βœ… Bucket Policy Used
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadAccess",
"Effect": "Allow",
"Principal": "",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/
"
}
]
}

After saving this, the website loaded successfully πŸŽ‰

πŸ‘€ Step 5: IAM User with Least Privilege

To follow security best practices, I created a dedicated IAM user.

IAM Steps:

Go to IAM β†’ Users

Create a new user

Enable AWS Management Console access

Attach AmazonS3ReadOnlyAccess

Login using the IAM user

πŸ”΄ Initially, I couldn’t see buckets due to missing permission:

s3:ListAllMyBuckets

After attaching the correct policy, it worked perfectly.

πŸ§ͺ Step 6: Verification

Website opened successfully via S3 endpoint

IAM user could access only S3

Images loaded correctly from assets/ folder

🌍 Final Output

βœ… Live static website
βœ… Secure IAM permissions
βœ… Public read-only S3 access

This project gave me hands-on experience with real AWS troubleshooting, not just theory.

πŸ“Œ Key Learnings

S3 is case-sensitive (important for images)

IAM permissions directly impact service visibility

Bucket policies override ACLs

Least privilege is critical for security

πŸ”— GitHub Repository

πŸ‘‰ (Add your GitHub repo link here)

🏁 Conclusion

This was a beginner-friendly but very practical AWS project.
It helped me understand how AWS services connect in real scenarios.

If you’re learning AWS, I highly recommend trying this project yourself πŸš€

GitHub--https://github.com/IrfanPasha05/aws-s3-static-portfolio/tree/main

πŸ™Œ Thanks for reading!

Feel free to connect or suggest improvements.

Top comments (0)