Menu
Amazon Simple Storage Service
Developer Guide (API Version 2006-03-01)

Example: Setting up a Static Website

You can configure an Amazon S3 bucket to function like a website. This example walks you through the steps of hosting a website on Amazon S3.

Step 1: Creating a Bucket and Configuring It as a Website

  1. Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.

  2. Create a bucket.

    For step-by-step instructions, see How Do I Create an S3 Bucket? in Amazon Simple Storage Service Console User Guide.

    For bucket naming guidelines, see Bucket Restrictions and Limitations. If you have a registered domain name, for additional information about bucket naming, see Customizing Amazon S3 URLs with CNAMEs.

  3. Open the bucket Properties pane, choose Static Website Hosting, and do the following:

    1. Choose Enable website hosting.

    2. In the Index Document box, type the name of your index document. The name is typically index.html.

    3. Choose Save to save the website configuration.

    4. Write down the Endpoint.

      This is the Amazon S3-provided website endpoint for your bucket. You use this endpoint in the following steps to test your website.

Step 2: Adding a Bucket Policy That Makes Your Bucket Content Publicly Available

  1. In the Properties pane for the bucket, choose Permissions.

  2. Choose Add Bucket Policy.

  3. Copy the following bucket policy, and then paste it in the Bucket Policy Editor.

    Copy
    { "Version":"2012-10-17", "Statement":[{ "Sid":"PublicReadForGetBucketObjects", "Effect":"Allow", "Principal": "*", "Action":["s3:GetObject"], "Resource":["arn:aws:s3:::example-bucket/*" ] } ] }
  4. In the policy, replace example-bucket with the name of your bucket.

  5. Choose Save.

Step 3: Uploading an Index Document

  1. Create a document. Give it the same name that you gave the index document earlier.

  2. Using the console, upload the index document to your bucket.

    For instructions, see Uploading S3 Objects in the Amazon Simple Storage Service Console User Guide.

Step 4: Testing Your Website

Type the following URL in the browser, replacing example-bucket with the name of your bucket and website-region with the name of the AWS Region where you deployed your bucket. For information about AWS Region names, see Website Endpoints ).

Copy
http://example-bucket.s3-website-region.amazonaws.com

If your browser displays your index.html page, the website was successfully deployed.

Note

HTTPS access to the website is not supported.

You now have a website hosted on Amazon S3. This website is available at the Amazon S3 website endpoint. However, you might have a domain, such as example.com, that you want to use to serve the content from the website you created. You might also want to use Amazon S3 root domain support to serve requests for both http://www.example.com and http://example.com. This requires additional steps. For an example, see Example: Setting up a Static Website Using a Custom Domain.