Amazon S3 can be used to host static websites, making them accessible via a unique S3-generated URL. This method is ideal for serving HTML, CSS, JavaScript, and images without the need for a web server.


1. Understanding S3 Website URLs

The website URL format depends on the AWS region where the bucket is created. The URL structure may look like:

http://<bucket-name>.s3-website-<region>.amazonaws.com

http://<bucket-name>.s3.<region>.amazonaws.com

The key difference between these formats is the use of a dash (-) vs. a dot (.) in the URL. However, AWS automatically assigns the correct format based on the region, so you don’t need to memorize them.


2. Steps to Enable S3 Static Website Hosting

  1. Create an S3 Bucket
  2. Upload Website Files
  3. Enable Static Website Hosting
  4. Make the Bucket Public

3. Setting Up Public Read Access

If the website returns a 403 Forbidden error, it means the bucket is not public. To fix this:

  1. Navigate to Permissions > Bucket Policy.
  2. Add the following policy:
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::your-bucket-name/*"
    }
  ]
}

🔹 Replace your-bucket-name with your actual S3 bucket name.