Amazon S3 Website Hosting Tutorial

In this short tutorial, we will get a static website up, hosted in Amazon S3. You might already use Amazon S3 to host images, video, and other website content. Now you can host an entire static website on Amazon S3. I assume you already have an AWS account. If you don’t, you can sign up now at the Amazon Simple Storage Service website.

1. First, login to your Amazon S3 Console.

2. Click “Create Bucket” and give it a unique name. I will call it s3.teamextension.com. Click the “Create” button to complete the creation of your new bucket.

Note that if you plan to use a custom domain, which we will dicusss more later, you will need to name your Bucket the same name as your custom domain.

3. Upload the static files you want hosted. For this tutorial, I created a file called index.html which contains the text “Hello from Amazon S3!”. I also created a file called error.html, which will get served if an error, like a 404, occurs. Now click “Upload” -> “Add files”.

Click on “Set Permission >” button and click on the “Make everything public” checkbox. Then click on “Start Upload”.

Note you can also look into Bucket Policies if you don’t want to set the permission for each file you upload.

3. Now right click on your newly created bucket and click on Properties. It will display a new Properties pane on the bottom of the console. Click on the Website tab. Click on Enabled, enter index.html for the Index Document, and error.html for the Error Document. Before clicking on “Save”, take note of the Endpoint listed. For our example, the endpoint is http://s3.teamextension.com.s3-website-us-east-1.amazonaws.com/.

4. Visit the endpoint URL you noted and you should see your index.html.

5. Now, that endpoint isn’t really our ideal website URL. We most probably want to use our own domain name. To accomplish this, go to your DNS provider and add a CNAME. For this example, we will add a CNAME using cPanel.

If you are unsure how to add a CNAME, contact your hosting provider. Note that it’s important that your bucket name matches your CNAME. Amazon S3 uses this to map the CNAME to the proper S3 Bucket.

Now go to http://s3.teamextension.com and you should see your fully working website.

For the official Amazon S3 guide, see Hosting Websites on Amazon S3.


About Javameme

Javameme is a Java news and article aggregator. Visit the site daily to be on top of what’s happening in the Java world. It also provides links to top Java resources on the web.

The site uses RSS content from Computerworld, Developer.com, DevX, DZone, eWeek, IBM developerWorks, InfoQ, James Gosling, Java Posse, java.net, Javalobby, JavaWorld, JDJ, NY Times, OnJava, Oracle Technology Network, Real’s How To, TeamEXtension, The Java Source, and TheServerSide.com. Please feel free to suggest other Java feeds we can use in the comments section below.

The website is implemented in Java SE 6, HTML5, jQuery and Soh Tanaka’s Smart Columns. Additional site functionality provided by Google Custom Search, Disqus and ShareThis. The design is inspired by StyleShout’s Keep It Simple template.