Day 14 of #30DaysOfAWSTerraform: Hosting a Static Website with S3 and CloudFront
Jenkins
Source: Dev.to | Dec 15, 2025 (UTC)
Day 14 was all about static websites and how AWS handles them at scale. Before this lesson, I had a surface-level idea of what a static website was, but today made everything click from how files are stored, to how they are securely served globally using AWS services.
The core focus of today’s lesson was S3, CloudFront, and how Terraform ties everything together as Infrastructure as Code.
Understanding Static Websites
A static website is exactly what it sounds like a site that serves fixed content such as HTML, CSS, JavaScript, images, and assets. There’s no backend logic, no database queries, and no server-side rendering. What you upload is what users see.
This makes static websites:
Fast
Cheap to host
Highly scalable
Secure when configured correctly
AWS excels at this through Amazon S3 and Amazon CloudFront.
Deep Dive into Amazon S3
S3 (Simple Storage Service) is not just a storage bucket it’s a highly durable object storage service designed to store and retrieve any amount of data.
Key things I deeply understood today:
S3 stores objects, not filesystems
Every object is accessed via a unique key
S3 is globally durable but regionally hosted
Public access must be explicitly controlled
In my setup, I created an S3 bucket using Terraform:
This ensures that the bucket cannot be accessed publicly unless explicitly allowed through CloudFront.
Uploading Website Files to S3
Instead of uploading files manually, Terraform can manage website content using aws_s3_object. This is powerful because your infrastructure and content stay in sync.
This automatically uploads HTML, CSS, and JavaScript from the www/ directory into S3 with correct content types.
Introducing CloudFront (The Game Changer)
CloudFront is AWS’s Content Delivery Network (CDN). Instead of serving content directly from S3, CloudFront caches content at edge locations close to users, dramatically improving performance and security.
I created an Origin Access Control (OAC) so CloudFront can securely access the S3 bucket:
This is a best practice for production-grade static websites.
Challenge Faced
I couldn’t fully complete the deployment because my AWS account wasn’t approved to create CloudFront distributions. That was frustrating, but also a real-world lesson: permissions and account limits matter.
Even so, the Terraform configuration is solid and production-ready.
Final Thoughts
Day 14 was a big milestone. I now understand:
How static websites work on AWS
Why S3 is ideal for hosting static content
How CloudFront improves performance and security
How Terraform ties everything together cleanly
This wasn’t just theory, it was real infrastructure thinking.
On to Day 15
For further actions, you may consider blocking this person and/or reporting abuse
Залишити відповідь