Host a static website

This is Part-1 of a multi-part blog post of how you can run a fast dynamic website in a completely serverless manner using managed services provided by AWS

In upcoming posts, we will explain

To use this method your website should be entirely made using HTML, CSS, JS only.

S3 Web hosting

Amazon S3 (Simple storage service)which is a widely popular storage service, supports static website hosting. You just need to put all your website files in an S3 bucket and then follow the steps below to get your website up and running in a few minutes with nearly no cost.

Bucket creation

The S3 Bucket name should be same as your website name. Example if your website is www.mywebsite.com then you will need to create bucket with name www.mywebsite.com. When you create the bucket make sure you select the region which is closest to your customers. Also a point to be noted here is S3 bucket names are globally unique. If someone already has a bucket with name MyBucket then you can’t create a bucket with the name MyBucket in any region.

Bucket Permissions

We are assuming that you are serving your website directly from S3.

Now we need to make all the files in this S3 bucket publicly readable. To do so you can set following permissions to the S3 bucket.

{
  "Version":"2012-10-17",
  "Statement": [{
    "Sid": "Allow Public Access to All Objects",
    "Effect": "Allow",
    "Principal": "*",
    "Action": "s3:GetObject",
    // Replace following with your website name.
    "Resource": "arn:aws:s3:::www.mywebsite.com/*" 
  }]
}

Enable website hosting

Now you are just a few steps away from making your website live. For this part logon to AWS Management Console and then go to S3 and select your website bucket and then go to bucket properties and enable Static Website Hosting.

We have just setup a static website now and we will share a lot more details in upcoming posts, so stay tuned.

Read more.