Website Hosting: linking your domain name to amazon s3 bucket
Every time I try to host my website I have to struggle with linking a domain name to the s3 bucket. So this time, I thought of writing an article with an intention to help future me.
There are some tutorials that help you around this, but almost all the articles mention about hosting site to a domain purchased in AWS route 53. Whereas in my case, I have purchased the domain in some third party site (crazydomain) and want a static hosting with s3.
The steps involved to host your site:
- Purchase a domain name of your choice. ( dummy.com )
- Create an s3 bucket with the same name. (dummy.com)
- Give public access to your bucket.
- Upload a index.html file to the bucket.
- Go to the bucket’s property and click on static website hosting.
- Give a name for your index document: index.html and save it.
7. Next, go to permission -> bucket permission and add the following
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::dummy.com/*"
}
]
}
Now you’ve to create a route:
8. Go to AWS Route 53 for creating a hosted zone.
9. Click on create a hosted zone and give the domain name as that of your s3 bucket.
10. Select the hosted zone just created and then select the record with NS type.
11. Click on create recordset. Let the name be as it is.
12. Select type as A-IPV4 address.
13. Select yes for alias.
14. Click on alias target, you should see your s3 bucket name. Select that.
15. Click on save recordset.
15. Select and copy all the NS values for your domain.
16. Update the NS value in your domain registry (in my case crazy domain) with the values we got in step 15.
17. Delete any A-records if present in your domain registry.
If you want to redirect www.dummy.com to dummy.com follow these steps:
18. Create another bucket with www.dummy.com's name and follow steps 2, 3, and 5.
19. On step 6 select redirect request and give the name of your old bucket ‘dummy.com’.
20. Enter the protocol as HTTP and save it.
21. Follow step 11 and add www in the given field.
22. Follow steps 12–15.
Wait for 24 hours and your site should be up and running.
Hope you found this article useful. I would love to hear your thoughts. 😇
Thanks for reading. 😊
Cheers! 😃
If you find this article useful, you can show your appreciation by clicking on the clap button. As the saying goes, ‘When we give cheerfully and accept gratefully, everyone is blessed’.