Hosting a website on Amazon S3

Setting up a static website

You can configure an Amazon S3 bucket to function like a website by following the below steps.

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

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

Step 3 : Uploading an Index Document

Step 4 : Testing Your Website

Creating a Bucket and Configuring It as a Website

(i) To create a bucket, click on “create bucket” and enter name of the bucket and the region where you want the bucket to reside.

(ii) Choose “next”.

(iii) On “set properties” page, you can configure the properties for the bucket according to the requirement.

(iv) On “set permissions” page you can manage the permissions.

(v) On “review” page you can verify the settings and choose edit in case if u want to edit your current settings.

(vi) Finally click on “create bucket”.

  • Open bucket “properties”, choose “static website hosting” and perform the following actions.

(i) Choose “Enable website hosting”.

(ii) In the “index Document box”, type the name of your index document.

(iii) Choose Save to save the website configuration.

(iv) Write down the Endpoint.

Adding a Bucket Policy That Makes Your Bucket Content Publicly Available

  • In the “Properties” pane, choose “permissions”.
  • Choose “Add Bucket Policy”.
  • Copy the following bucket policy, and then paste it in the Bucket Policy Editor.
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadForGetBucketObjects",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::example-bucket/*"
]
}
]
}
  • In the policy, replace example-bucket with the name of your bucket.

Choose Save.

Uploading an Index Document

  • Create a document. Give it the same name that you gave the index document earlier.
  • Using the console, upload the index document to your bucket.

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.

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

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

Show your support

Clapping shows how much you appreciated Sri Teja’s story.