AWS S3 is used to host the static website. We can use the s3 endpoint to redirect the website to a specific domain. No web server is required to handle the redirection of the website.
A static website hosted using Amazon S3. Refer to the article How to host a static website on S3 for reference.
Note: Your domain name should be the same as that of bucket name.
For example, we used a bucket name and domain name as example.zehntech.net.
In the article How to host a static website on S3, we created a static website but it is only accessible via the bucket endpoint. To make it accessible via custom domain follow the below steps:
Step 1: Login to the AWS console.
Step 2: Select the Route 53 service form list of services.
Step 3: You need to register your domain with Amazon Register. Once it is done you will have a hosted zone with two record sets one for Name Server (NS) and another for SOA.
Step 4: Create another record set in the domain by clicking on Create Record Set.
Step 5: Enter the name of the Record Set. As we used a bucket name as example.zehntech.net so our Record Set name will also be example and zehntech.net is the name of Hosted Zone.
Step 6: The Type is by default as A-IPv4 address leave the type as this only.
Step 7: The default value for Alias is “No”. As we want to host a static website from S3 bucket we need to make this Alias as “Yes”.
Step 8: Set the Alias Target name as the name of the S3 bucket. If you have the S3 bucket created in the same Amazon account then on clicking the text-box for Alias Target it will display the S3 bucket endpoints whose name is same as that of the domain name. So, select the S3 bucket endpoint.
Step 9: Click on Create to create a record set.
Step 10: Open the domain created in the browser. It will show the starting page which is given in index.html option of Static Website hosting in S3. See the output of the domain we created as example example.zehntech.net in the browser.
Note: The record sets take time to propagate to the Route 53 DNS servers. It usually takes couple of minutes to propagate to all Route 53 but in some cases, it may take up to 30 minutes also.