Project: Hosting a Static Website on AWS S3: A Step-by-Step Guide

Project: Hosting a Static Website on AWS S3: A Step-by-Step Guide

Efficient and Cost-Effective: AWS S3 Hosting for Your Static Website

Goal:

In this project, we will demonstrate how to host a static website on AWS S3. Hosting a static website on S3 is a simple and cost-effective way to serve a website with high availability, scalability, and low latency. With AWS S3, we can store and distribute web content with ease, without the need to manage and configure servers.


Prerequisites:

Before we start, we should have the following prerequisites:

  • An AWS account

  • A registered domain name

  • A static website with HTML, CSS, and JavaScript files


Project Steps:

  1. Create an S3 bucket:

    • Log in to the AWS Management Console and go to the S3 service

    • Click "Create Bucket" and follow the prompts to create a bucket with a DNS name

  2. Configure bucket properties:

    • Enable static website hosting in the bucket properties

    • Specify an index document and error document for your website

  3. Upload website files:

    • Upload your static website files to the S3 bucket

  4. Configure bucket permissions:

    • Add a bucket policy to make the website files public

    •   {
            "Version": "2012-10-17",
            "Statement": [
                {
                    "Sid": "PublicRead",
                    "Effect": "Allow",
                    "Principal": "*",
                    "Action": [
                        "s3:GetObject",
                        "s3:GetObjectVersion"
                    ],
                    "Resource": "arn:aws:s3:::<bucket-arn>/*"
                }
            ]
        }
      

    • Enable public access

  5. Configure Route53:

    • Create a Public hosted zone

    • Configure with a domain registrar

  6. Create Record:

    • Create a Record name with a CNAME record type in Route53 hosted zone

    • In the value, section add an S3 Bucket properties sections Static website hosting endpoint

  7. Verify the website is working:


Conclusion:

In this project, we demonstrated how to host a static website on AWS S3. By following the above steps, you can easily host a website with low cost, high availability, and scalability. AWS S3 makes it easy to manage and distribute web content without worrying about managing servers.