Static Website Hosting on AWS Using S3, Route 53, ACM, and CloudFront (Terraform)

Biswanath SahBiswanath Sah
3 min read


In this project, I deployed a static website hosted on Amazon S3, secured with SSL/TLS using AWS Certificate Manager (ACM), and distributed globally with low latency through Amazon CloudFront. The infrastructure was fully provisioned using Terraform, ensuring a reproducible, automated, and scalable deployment process. To make the website accessible via a custom domain, I used Amazon Route 53 for DNS management, routing domain traffic to the CloudFront distribution efficiently and reliably.

⚙️ AWS Services Used

  • Amazon S3 (Simple Storage Service)
    Used to store and deliver the static website content, such as HTML, CSS, and JS files.

  • Amazon CloudFront
    A global content delivery network (CDN) that caches and delivers the S3 content with low latency and high availability.

  • AWS Certificate Manager (ACM)
    Provides the SSL/TLS certificate to enable secure HTTPS access via CloudFront.

  • Amazon Route 53
    A scalable DNS service used to manage the custom domain and route DNS queries to CloudFront.

  • Terraform
    Infrastructure as Code (IaC) tool used to automate the provisioning of all AWS resources—ensuring repeatability, version control, and clean teardown if needed.


📜 Step-by-Step Guide

1. Create S3 Bucket and Upload Website Files

  • Create an S3 bucket to store the website files (HTML, CSS, images, etc.).

  • Set the bucket name to match your domain (e.g., biswas.me).

  • Upload files like index.html, error.html, styles.css, etc.

Configure Access:

  • Set aws_s3_bucket_public_access_block with all attributes as false to allow public access:

  • Add a aws_s3_bucket_policy to allow public read access:

  • Configure aws_s3_bucket_website_configuration with index.html and error.html.

  • Visit the S3 website endpoint URL to verify that the site is accessible.

2. Create Route 53 Hosted Zone

  • Create a hosted zone for your domain (eg: biswas.me).

  • Get the name servers from Route 53 and update them in your domain registrar’s DNS settings.

3. Request SSL Certificate (AWS Certificate Manager)

  • Use ACM to request a public certificate.

  • Add two domain names:

    • custom_domain_1

    • custom_domain_2

  • Create DNS validation records in Route 53.

  • Wait for the certificate status to be ISSUED.

4. CloudFront Configuration

  • Create a CloudFront distribution:

    • Set origin to S3 bucket website endpoint (HTTP only, port 80).

    • Enable redirect HTTP to HTTPS for the viewer protocol policy.

    • Do not enable WAF (Web Application Firewall).

    • Add alternate domain names (CNAME): biswanathsah.me, www.biswanathsah.me

    • Attach the custom SSL certificate from ACM.

    • Set default root object: index.html

5. Final Step: Add Route 53 Alias Records for CloudFront

  • Create two A type alias records pointing to the CloudFront distribution:

✅ Once complete, visiting domain url that will serve your static site securely over HTTPS using CloudFront CDN.

💡 Wrapping Up

By combining AWS services like S3, CloudFront, ACM, and Route 53 with the power of Terraform, we successfully built a secure, scalable, and globally accessible static website infrastructure. This project not only demonstrates the effectiveness of Infrastructure as Code (IaC) for automating deployments, but also highlights best practices in cloud architecture - including HTTPS encryption, custom domain integration, and CDN-based performance optimization.

0
Subscribe to my newsletter

Read articles from Biswanath Sah directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Biswanath Sah
Biswanath Sah