Galle, LK--:--5/6 sites live

Amazon S3 (Simple Storage Service) & Static Hosting

Amazon S3 provides object storage designed for 99.999999999% (11 9's) of data durability. Unlike block storage (EBS) or filesystem storage (EFS), S3 stores data as objects with metadata and a unique key…

14 Jun 20263 min readSelf Guide · Stage 5#AWS#IAM#W3DevOps

Lesson 14 of 26 · Module: AWS

20 min read · Source notes — Static Website Hosting in AWS S3

Amazon S3 provides object storage designed for 99.999999999% (11 9's) of data durability. Unlike block storage (EBS) or filesystem storage (EFS), S3 stores data as objects with metadata and a unique key across flat namespaces.

Screenshot: S3 Static Website Hosting

Enabling static website hosting, configuring index.html and error document redirection.

1. S3 Storage Tiers & Cost Optimization

Storage ClassAvailabilityCost per GBIdeal DevOps Scenario
S3 Standard99.99%$0.023 / GBActive websites, frequently accessed user uploads, CI/CD artifacts.
S3 Standard-IA (Infrequent Access)99.9%$0.0125 / GBDisaster recovery backups and long-term storage accessed less than once a month.
S3 Glacier Flexible Retrieval99.99%$0.0036 / GBArchived log files, database dumps retained for regulatory audit compliance.
S3 Glacier Deep Archive99.99%$0.00099 / GBCold archives stored for 7–10 years (retrieval takes 12–48 hours).

2. Hosting a Production React / Vue SPA on S3

To host a Single Page Application (SPA), the bucket needs public read access and an Index Document configuration:

Public Read Bucket Policy

ExampleJSON
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicReadGetObject",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::my-frontend-app-prod/*"
    }
  ]
}

The SPA Routing Trap: Why 404 Routing Matters

In client-side SPAs (React Router, Next.js, Vue), URLs like /dashboard or /profile do not exist as physical files on S3! When a user refreshes the page, S3 returns a 404 Not Found. To fix this:

Set both Index Document and Error Document to index.html in the S3 Website Hosting tab or CloudFront custom error response!


Keep going: ← Lesson 13 · Lesson 15 → · Module overview · Track it in the Self Guide