Is there a way to have index.html functionality with content hosted on S3?

Amazon S3 now supports Index Documents

The index document for a bucket can be set to something like index.html. When accessing the root of the site or a sub-directory containing a document of that name that document is returned.

It is extremely easy to do using the aws cli:

aws s3 website $MY_BUCKET_NAME --index-document index.html

You can set the index document from the AWS Management Console:

enter image description here


For people still struggling against this after 3 years, let me add some important information:

The URL for your website (and to which you have to point your DNS) is not

<bucket_name>.s3-us-west-2.amazonaws.com, but

<bucket_name>.s3-website-us-west-2.amazonaws.com.

If you use the first, it will not work as intended, no matter how much you config the Index document.

For a specific example, consider:

  • http://www-example-com.s3.amazonaws.com/index.html works.
  • http://www-example-com.s3.amazonaws.com/ fails with AccessDenied.
  • http://www-example-com.s3-website-us-west-2.amazonaws.com/ works!

To get your true website address, go to your S3 Management Console, select the target bucket, then Properties, then Static Website Hosting. It will show the website URL that will work.