Day #7 :AWS S3-Part II. Hosting a static website on Amazon S3 storage.

Day #7 :AWS S3-Part II. Hosting a static website on Amazon S3 storage.

In this post we will be learning about hosting a website on AWS S3 bucket. Nowadays websites are becoming static websites it means they dont require server to run and consist of only HTML, CSS and JavaScript. For that AWS s3 is the perfect example to host a website instead of traditional server approach.

Using S3 cost $1-$2 a month depending upon the usage as compare to having a cost of server and maintenance and While we can leverage s3 high scalability and high performance for our site. for more about s3 you can check my previous post AWS S3.

Some serious benefits of using s3

  1. Low cost — You will be paying only S3 standard charges and data transfer charges.
    • GET Requests cost $0.004 per 10,000 requests
    • Data Transfer Out cost $0.090 per GB (up to 10 TB / month)
  2. Maintenance — No Need for maintenance AWS will make it up to date.
  3. Scale — S3 is a high availability and durable service that AWS maintains. If your website goes from 10 users a day to 10 million, S3 scales your website automatically.
  4. Security — There is no server so less vulnerability.

Lets get started.

Create a bucket. Make sure to name the bucket its mandatory and should be same as your domain name. Upload your static content site in the bucket under s3 standard class.

Change Permission and allow public permissions and apply bucket policies and also please keep in mind not to upload any data that you don’t want to share with public.

{
    "Version": "2008-10-17",
    "Id": "PolicyForPublicWebsiteContent",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "YOUR-BUCKET-ARN"
        }
    ]
}

Select Static web hosting under properties and select your starting html page.


You can copy the endpoint and Test it will started working.

Our Site has been hosted on S3 and can be accessible through S3 bucket url. Lets connect the site with the Domain Name.

Adding CNAME with bucket url.

Create a hosted zone. and add domain registration if not having a domain name. if you have a domain name Just add CNAME records mapping your bucket URL with your Domain Name.

The process to complete this step varies depending on who your DNS provider is. In general this is what you are looking for within your DNS provider:

  • Create a record for a host like www
  • The record type must be CNAME (Canonical name)
  • The value must be your S3 website url www.your-bucket-url.s3-website-us-east-1.amazonaws.com

I hope this post helped you and Please leave a comment if you want to know more about it or about your likes dislikes about it. Thanks for reading.

2 thoughts on “Day #7 :AWS S3-Part II. Hosting a static website on Amazon S3 storage.

    1. admin Post author

      Hi Sepia,

      Can you please let me know what you find invaluable and what you want to find more and help me to improvise the content.
      Thanks

Comments are closed.