"Waitβyouβre telling me I can host a website without a server... for pennies... and it's secure?" YES. And it's easier than you think.
Letβs walk through itβstep by step, no jargon, just results.
π§ Why Use S3 for Hosting?
Amazon S3 (Simple Storage Service) is perfect for static websitesβsites made with HTML, CSS, JS, no backend (like blogs, portfolios, docs, landing pages).
β Key Benefits:
- Cheap (free for first 5GB on Free Tier)
- Scalable (same tech used by Netflix!)
- No servers to manage
- Custom domain support
- Free SSL via CloudFront
Real-world analogy: Think of S3 as a super-secure Dropbox that can also serve your files to the whole internet as a website.
π οΈ What Youβll Need
- An AWS account
- A static website (e.g.,
index.html
,style.css
) - A domain (from Route 53 or GoDaddy)
π Step 1: Upload Your Site to S3
1. Create an S3 Bucket
- Go to S3 Console
- Bucket name = your domain name (e.g.,
myportfolio.dev
) - Uncheck "Block all public access"
2. Upload Your Files
- Upload your HTML/CSS/JS files into the bucket
3. Enable Static Website Hosting
- Go to Properties tab β Scroll to Static Website Hosting β Enable
- Set
index.html
as Index Document
4. Make Files Public
Go to Permissions tab β Edit Bucket Policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::myportfolio.dev/*"
}
]
}
Now visit the bucket's website endpoint β Your site is live! π
π Step 2: Connect Your Custom Domain
Option A: Using Route 53 (AWS DNS)
- Go to Route 53 β Hosted Zones β Create one for
myportfolio.dev
- Create an A Record (Alias) pointing to the S3 website endpoint
Option B: Using GoDaddy or Others
- Go to your domain registrar
-
Edit DNS records:
- Type: A Record (or CNAME)
-
Value: S3 website endpoint (e.g.,
myportfolio.dev.s3-website-us-east-1.amazonaws.com
)
Note: S3 endpoints donβt support HTTPS directlyβthatβs where CloudFront comes in.
π Step 3: Add SSL (HTTPS) Using CloudFront
1. Create a CloudFront Distribution
- Origin domain = S3 bucket website endpoint (not the bucket name!)
- Enable Redirect HTTP to HTTPS
- Set default root object =
index.html
2. Request a Free SSL Certificate (ACM)
- Go to AWS Certificate Manager
- Request public cert for
myportfolio.dev
andwww.myportfolio.dev
- Validate via DNS (Route 53 makes this easy)
3. Attach Certificate to CloudFront
- Go back to CloudFront β Select your distribution β Edit β Add SSL cert
4. Update DNS
- Final step: Update your domainβs A record to point to the CloudFront distribution domain (e.g.,
d1234abcd.cloudfront.net
)
Boom! Now your site is served over HTTPS with blazing-fast performance π₯
π¦ Summary (The Flow)
Local Files β S3 β CloudFront β Custom Domain + HTTPS
Step | Tool Used |
---|---|
Host Files | Amazon S3 |
Serve Globally | CloudFront |
Domain Mapping | Route 53 or GoDaddy |
SSL | AWS Certificate Manager |
π Final Thoughts
Hosting static sites with S3 is like magic when you first do it. Fast, secure, reliableβand youβre in full control.
And once you do it once, you'll never go back to shared hosting again.
π¬ Over to You!
Did this guide help you host your first static site? Have questions about custom domains or SSL setup?
π Drop your questions in the comments, hit β€οΈ if this saved you hours, and share this with someone trying to deploy their portfolio!
Letβs make modern web hosting accessible to everyone. π§‘
Top comments (0)