Hosting a Static Site in Amazon S3 using your Domain

  • Cloud Services
Mon Apr 24 by Moorthy M

A webserver is not always required to host websites! Yeah you read that right. You can host your website just using Amazon S3. But it should be a static site i.e.,. it should serve only static content and client side scripts. This reduces costs and adds the benefit of being hosted in a well architected infrastructure.

NOTE: A dynamic website which requires server power for processing containing scripts such as PHP, JSP or ASP.NET, etc.,. cannot be hosted using S3. A dynamic website can only be hosted in resources such as an EC2 instance.

Registering the domain:

The domain name have to be registered at a registrar if it is not registered already. We will be using the domain yourdomain.com with Amazon Route 53 as the DNS servers.

Configuring the S3 Buckets:

Two S3 buckets have to be created. One with the www subdomain and another without for example, two buckets namely yourdomain.com and www.yourdomain.com.One bucket will be containing the site’s content (bucket named yourdomain.com) and the other will be redirecting the http requests to the S3 bucket containing the site’s content.

You can create a homepage for your website and name it as you want. This file name will be specified as the index document for your website.The buckets have to be configured so that the objects inside the buckets are publicly accessible. The following bucket policy needs to be attached to the bucket yourdomain.com.

"Principal": "*",

You have now created two S3 buckets and uploaded our site’s content to yourdomain.com. You now need to configure the bucket www.yourdomain.com so that all http requests are redirected to yourdomain.com. You can maintain only one copy of your website by redirecting requests.

To Configure the bucket yourdomain.com for website hosting:

1. Sign in to the AWS Management Console and open the Amazon S3 console at https://
2. Choose the bucket yourdomain.com.
3. Choose Properties.
4. Choose Static website hosting.
5. Configure yourdomain.com bucket for website hosting. In the Index Document box, type the name that you gave your index page.
6. Choose Save.

To redirect requests from www.yourdomain.com to yourdomain.com:

1. In the Amazon S3 console, in the Buckets list, choose www.yourdomain.com.
2. Choose Properties.
3. Choose Static website hosting.
4. Choose Redirect requests. In the Target bucket or domain box, type yourdomain.com.
5. Choose Save.

The website can be tested via region specific endpoint URLs such as the below:


The site cannot be accessed via your domain name as of now.

Configuring Hosted zone for your domain in Amazon Route 53:

A Hosted zone for yourdomain.com has to be created in Amazon Route 53. A list of Amazon Route 53 name servers will be displayed for the domain which has to be specified at the registrar. An alias record has to be added to map yourdomain.com to the bucket yourdomain.com.

A second alias record to map the subdomain www.yourdomain.com to the www.yourdomain.com bucket. After DNS propagation, the site can be tested by loading yourdomain.com directly in the browser. You have saved some dollars which would have otherwise spent on a webserver for hosting your static site!


Ready to Build Your Projects?

The best companies and startups hire our top dev teams, and so can you.
Start a Project
GSM Plus Infotech