S3 hosting static website


This method hosts the static website in a similar way that github pages do. It is quite similar to host a website with dynamic domain name, since they are all based on amazonaws.com root domain.

Steps

  1. Enter your s3 Service interface. (Services → Storage Category → S3)
  2. Create bucket, name it like a website url.
  3. Upload a index.html file.
  4. Upload an error.html file so that if the browser enters a page that does not exist, this page will be shown.
  5. Go into your website bucket → Adjust Settings → Static website hosting Enable → Specify index.html and error.html.
  6. Go to Permissions → Edit Block Public Access → Unlock Block all Public Access.
  7. Edit Bucket Policy,
  8. 
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "PublicReadGetObject",
                "Effect": "Allow",
                "Principal": "*",
                "Action": "s3:GetObject",
                "Resource": "arn:aws:s3:::{url}/*" ## please replace url with your website domain name
            }
        ]
    }
        
  9. Objects Tab → Select all files → Actions → Make Public
  10. Now you can see your page with accessible endpoint, in format http://{url}.s3-website.{region}.amazonaws.com .

References