Enable static website hosting in S3

AWS Simple Storage Service (S3) offers one of the powerful capability to host static websites. In this post let’s cover the steps for the same.

Create a sample bucket by name ‘mytestdomain.com’. The convention is that bucket name should match with the website domain name.

In this case the domain name for the static website is mytestdomain.com. The S3 bucket should match that name.

image

Enable public read access to this bucket.

image

Enable static web site hosting for the bucket by selecting ‘Use this bucket to host a static website’ and specifying the index document and error document.


image

Upload the index.html and error.html file and grant the public read access to it. Now access the static website url

provided by S3. It should be in this format.

http://s3bucketname.s3-website-region.amazonaws.com/

It should render the index.html in the browser

image

To render this website with the actual domain name, we need to leverage Route 53 DNS service offered by AWS.

Create a hosted zone for our custom domain.

image

Once the hosted zone is created, S3 presents with list of name servers. It should be mapped with the domain registrar for routing the request through Route 53.

The next step is to create a Record Set for the Hosted Zone bye selecting the Alias Target to the S3 bucket enabled for static website hosting.

image

It takes few minutes for the record set changes to get propagated. After that try accessing the website domain url. It should render the index page. This completes this article.





Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.