If you want to host your own website using AWS then lets get ready 🙂 In this blog we are going to host a website on Amazon S3 and will route the traffic to S3 buckets through route 53 plus doing health check. To configure your bucket for static website hosting, you can use the AWS Management Console without writing any code.


Prerequisite:

  • Before going to perform this use case, we have to create a domain name. We can create domain names using Route 53 or any other DNS service.
  • Create a bucket – S3 bucket name must match with the DNS name which is the name of the website that you are hosting.

Objective:

Amazon S3 can be used to host a static website as well as a dynamic website. AWS SDKs provide wrapper classes around the Amazon S3 REST API with which we can programmatically create, update and delete the website configurations.

In this use case we are going to host a website on Amazon S3 and will route the traffic to S3 buckets using route 53. Also going to do a health check.

Before going to perform this use case, we have to create a domain name. We can create domain names using Route 53 or any other DNS service. I have created a domain name using a free domain name service provider. My domain name is testusecase.com.

Now we are going to configure the S3 bucket for website hosting. Below are the steps to host it.


  1. Create a primary bucket with Domain Name

My domain name is testusecase.com and we have to create a bucket with the same name as that of the domain name. In this bucket we will upload a static website. Click on create

  1. Enable public access and versioning for this website. Then click on create bucket. By enabling public access, anyone on the internet can access our website.
  1. To host static websites on Amazon S3, we have to enable a static hosting option.
  1. Edit Bucket Policy. Using the policy generator you can create it or can access from the document.
{ "Version": "2012-10-17",
 "Statement": [ {
   "Sid": "PublicReadGetObject",
   "Effect": "Allow",
   "Principal": "*",
   "Action": [ "s3:GetObject" ],
   "Resource": [ "arn:aws:s3:::bucket-name/*" ]
  }]
}
  1. Create a redirect for the S3 bucket for the sub-domain. To make ‘www.testusecase.com’ work, we are setting a redirect bucket for this subdomain.
  1. Create this bucket with the same step as created above except disabling all public access.
  1. Enable static website hosting redirect by choose the properties option from bucket settings.
  1. Now upload a static website in the Amazon S3 bucket.
  1. After uploading we can check our website with the provided endpoint.

Kindly comment here or mail us support@data-stats.com and edugenixcloud@gmail.com in case of any doubts. We will reach you as soon as possible.

Categories: AWS

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Insert math as
Block
Inline
Additional settings
Formula color
Text color
#333333
Type math using LaTeX
Preview
\({}\)
Nothing to preview
Insert