{"id":20,"date":"2023-01-09T23:30:00","date_gmt":"2023-01-09T23:30:00","guid":{"rendered":"https:\/\/shagun.dev\/?p=20"},"modified":"2025-01-08T20:52:57","modified_gmt":"2025-01-09T01:52:57","slug":"how-to-host-website-for-free-using-aws-s3","status":"publish","type":"post","link":"https:\/\/shagun.dev\/?p=20","title":{"rendered":"How to host website using AWS S3"},"content":{"rendered":"\n<p>AWS Service Used : S3<\/p>\n\n\n\n<p>The following are the steps to be taken in order to do so:<br><br>1. Create a bucket named as test-aws-01<\/p>\n\n\n\n<!--more-->\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"954\" src=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.33.58-PM-1-1024x954.png\" alt=\"\" class=\"wp-image-26\" srcset=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.33.58-PM-1-1024x954.png 1024w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.33.58-PM-1-300x280.png 300w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.33.58-PM-1-768x716.png 768w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.33.58-PM-1.png 1466w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>2. Put all default settings while creating bucket<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"431\" src=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.38.27-PM-1024x431.png\" alt=\"\" class=\"wp-image-27\" srcset=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.38.27-PM-1024x431.png 1024w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.38.27-PM-300x126.png 300w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.38.27-PM-768x323.png 768w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.38.27-PM-1536x647.png 1536w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.38.27-PM-2048x863.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>3.  Upload or drag build folder files. If react app, run these commands to get production code<br>      <code>npm install<\/code><br>      <code>npm run build<\/code><\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"517\" src=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.44.36-PM-1024x517.png\" alt=\"\" class=\"wp-image-28\" srcset=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.44.36-PM-1024x517.png 1024w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.44.36-PM-300x151.png 300w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.44.36-PM-768x387.png 768w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.44.36-PM-1536x775.png 1536w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-09-at-11.44.36-PM.png 1994w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>4. Go to Properties tab, go to Static website hosting. Enable the static website under static website and host type as host as a static website<\/p>\n\n\n\n<p>5. Specify the home or default page of the page. In the above example, the default file would be index.html<\/p>\n\n\n\n<p>6. You can also add error document if present in your project<\/p>\n\n\n\n<p>7. Make sure that in order to make this project live, you need to remove the blocked public access under permissions<\/p>\n\n\n\n<p>8. Edit a bucket policy, click on Add new statement button from the right side. Search S3 service in the filter search text. Then, search GetObject action in the filter actions<\/p>\n\n\n\n<p>9. Add resource, choose Resource Object as object. Resource ARN would look like:<br>arn:aws:s3:::{BucketName}\/{ObjectName}<br>Replace the bucket name to test-aws-01 and change ObjectName to *<br>Principal should be replaced by *<\/p>\n\n\n\n<p>10. Save changes. The final bucket policy look like as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"804\" src=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-12.01.28-AM-1024x804.png\" alt=\"\" class=\"wp-image-29\" srcset=\"https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-12.01.28-AM-1024x804.png 1024w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-12.01.28-AM-300x236.png 300w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-12.01.28-AM-768x603.png 768w, https:\/\/shagun.dev\/wp-content\/uploads\/2023\/01\/Screenshot-2023-01-10-at-12.01.28-AM.png 1110w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>11. In order to get object url of index.html go to bucket &gt; look for index.html. The. properties will have object url copy it and paste to browser. <br>12. Your website got live !<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>AWS Service Used : S3 The following are the steps to be taken in order to do so: 1. Create a bucket named as test-aws-01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-20","post","type-post","status-publish","format-standard","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/shagun.dev\/index.php?rest_route=\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shagun.dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shagun.dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shagun.dev\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shagun.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=20"}],"version-history":[{"count":17,"href":"https:\/\/shagun.dev\/index.php?rest_route=\/wp\/v2\/posts\/20\/revisions"}],"predecessor-version":[{"id":141,"href":"https:\/\/shagun.dev\/index.php?rest_route=\/wp\/v2\/posts\/20\/revisions\/141"}],"wp:attachment":[{"href":"https:\/\/shagun.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shagun.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shagun.dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}