Posts

Showing posts from May, 2026

Day 14 - Static Website Hosting using Terraform

Image
Today I worked on my first mini project in my AWS Terraform journey. The goal was to deploy a static website using S3 and CloudFront. Instead of manually creating resources in AWS, I used Terraform to automate the entire setup. Architecture User requests first hit CloudFront. CloudFront securely fetches content from a private S3 bucket using Origin Access Control and delivers it globally. User → CloudFront → Private S3 Bucket Project Setup I organized my Terraform code into multiple files for clarity. Variables, provider configuration, and main resources are separated. S3 Bucket The S3 bucket stores the website files. Public access is completely blocked. This ensures that the bucket is not exposed directly to the internet. Uploading Files Terraform automatically uploads all files from the local www folder. This includes index.html, style.css, and script.js. I used a loop with fileset to avoid writing multiple resource blocks. CloudFront Distribution CloudFront acts ...