Web App Development

Hosting a static website on Amazon S3

Here's how to host a static site on S3:
  1. Create a bucked with the full domain name of your website (so in my case www.mostlystatic.com)
    Your website is now available at .s3-website-us-east-1.amazonaws.com
  2. Add a CNAME entry to your DNS records:
    Subdomain: www
    CNAME: www.example.com.s3-website-us-east-1.amazonaws.com.
    Once the DNS changes have propagated you'll be able to access the bucket on your domain.
If there's nothing in the bucket you'll now see something like this:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<error>
<code>AccessDenied</code>
<message>Access Denied</message>
...
</error>

Add an index document

To set a document as the homepage do the following:

  1. Upload an html file to the S3 bucket and make it public
  2. Go to the S3 bucket list in the AWS Console
  3. Right-click on the bucket containing your website and select "Properties" in the context menu
  4. Under "Website" check "Enabled" and enter the filename of the html page
  5. Click Save

Change bucket permissions (optional)

In the "Permissions" section of the bucket properties you can make all files in the bucket publicly available at once. Add a new permissions and check the "View Permissions" box. Then save the changes.

Comments


Follow me on Twitter
I'm building monitoring tool for site speed and Core Web Vitals.
➔ Start monitoring your website or run a free site speed test