Day 14 was exciting because I applied everything I’ve learned so far in my first mini-project: hosting a static website using AWS S3 and CloudFront, all managed with Terraform. It was hands-on, practical, and a big confidence booster.
Project Overview
The goal was to:
- Host a static website in an S3 bucket
- Make it securely accessible via CloudFront
- Manage everything through Terraform
Along the way, I learned how to handle public access, bucket policies, and CloudFront origin access control.
Key Steps I Followed
- Create an S3 Bucket I started with a simple S3 bucket to host the website:
- I kept the bucket private and enabled website hosting.
This ensures content is served only through CloudFront for security.
Configure Public Access & Bucket Policy
To allow CloudFront to access the bucket without making it public:
- Using Origin Access Identity (OAI) ensures S3 content is private and only accessible via CloudFront
- Set Up CloudFront Distribution
CloudFront handles content delivery and caching for the website:
- CloudFront caches content globally and serves it over HTTPS.
- The OAI ensures only CloudFront can access the S3 bucket.
- Upload Website Files
I used Terraform’s aws_s3_bucket_object to upload HTML, CSS, and images:
- Terraform can manage the content itself, not just infrastructure.
Key Learnings
- S3 Bucket & Public Access: Keep buckets private and serve content via CloudFront.
- CloudFront Origin Access Control: Protects your content while allowing secure delivery.
- Bucket Policies: Essential for controlling who can access objects.
- Terraform Automation: I realized how Terraform can manage both infrastructure and content together.
- Real-World Flow: From bucket creation → policy → CloudFront → upload → serve.
Final Thoughts
Completing this mini-project made Terraform feel very real and practical. It was amazing to see a website live just from my configuration files.
This project also gave me confidence to tackle more complex setups like multi-region hosting, SSL certificates, or CI/CD integration with Terraform.
Top comments (1)
Hi this looks good , nice article but you don't demonstrate in anyway how you use terraform to achieve this on anything so it will be good if you also include that you article thank you @sreya_sharma_711168ec58fc