DEV Community

Cover image for ๐ŸŒDevOps and Cloud Project: Static Website Hosting with AWS S3 + CloudFront + CI/CD
Ritesh Singh
Ritesh Singh

Posted on

๐ŸŒDevOps and Cloud Project: Static Website Hosting with AWS S3 + CloudFront + CI/CD

PROJECT OVERVIEW

This project demonstrates how to host a static website on Amazon S3, deliver it globally with CloudFront CDN, and automate deployments using GitHub Actions.


๐Ÿš€ Features

  • โœ… Static website hosting on Amazon S3
  • โœ… CloudFront CDN for global fast delivery + HTTPS
  • โœ… CI/CD pipeline with GitHub Actions (auto-deploy on push)
  • โœ… Cache invalidation so updates are live instantly
  • โœ… Secure Origin Access Control (OAC) โ†’ S3 is private, only CloudFront can access

๐Ÿ—๏ธ Architecture Workflow

๐Ÿ”น Request Flow

User โ†’ CloudFront (Edge Cache) โ†’ [If cache miss] โ†’ S3 Bucket โ†’ CloudFront โ†’ User

๐Ÿ”น Deployment Flow

Developer โ†’ GitHub Repo โ†’ GitHub Actions โ†’ S3 Bucket โ†’ CloudFront โ†’ End User


โš™๏ธ Setup Instructions

1๏ธโƒฃ Create S3 Bucket

  • Go to AWS S3 Console
  • Create a bucket (region example: ap-south-1)
  • Keep Block Public Access = ON
  • Upload your static website files (index.html, CSS, JS, images, etc.)


2๏ธโƒฃ Create CloudFront Distribution

  • Open CloudFront Console โ†’ Create Distribution
  • Origin = your S3 bucket
  • Use Origin Access Control (OAC) (so only CloudFront can read from S3)
  • Copy the CloudFront domain (e.g., d1234abcd.cloudfront.net)




3๏ธโƒฃ Configure GitHub Actions


๐Ÿ”‘ Secrets Setup in GitHub

Go to GitHub Repo โ†’ Settings โ†’ Secrets and variables โ†’ Actions โ†’ New repository secret

Add:

  • AWS_ACCESS_KEY_ID

  • AWS_SECRET_ACCESS_KEY


๐ŸŒ Access Your Website

Default โ†’ (your CloudFront domain)

Optional โ†’ Add Route 53 + ACM SSL to use a custom domain

๐Ÿ“Œ Future Improvements

Add CloudWatch monitoring & logging

Add Route 53 + SSL certificate for a custom domain

Extend pipeline with tests before deployment

๐Ÿ† Learning Outcome

By completing this project, I learned:

How to use AWS S3 for static hosting

How CloudFront works as a CDN with OAC

How to build a CI/CD pipeline with GitHub Actions

How to automate deployments and cache invalidations


๐Ÿ”— Keywords: AWS, S3, CloudFront, GitHub Actions, CI/CD, DevOps, Cloud
๐Ÿš€Github

โšก Now, every time I push code to GitHub, my website auto-deploys to AWS with CloudFront CDN ๐Ÿš€

Top comments (0)