
{"id":24,"date":"2025-05-30T16:59:27","date_gmt":"2025-05-30T15:59:27","guid":{"rendered":"http:\/\/blog.mkcloudai.com\/?p=24"},"modified":"2025-05-31T13:39:27","modified_gmt":"2025-05-31T12:39:27","slug":"how-to-use-amazon-s3-for-static-website-hosting","status":"publish","type":"post","link":"https:\/\/blog.mkcloudai.com\/?p=24","title":{"rendered":"How to Use Amazon S3 for Static Website Hosting"},"content":{"rendered":"\n<p>Amazon Simple Storage Service (S3) is a highly scalable, durable, and secure object storage service offered by AWS. One of its popular use cases is hosting static websites \u2014 websites that consist of HTML, CSS, JavaScript, and media files without server-side processing.<\/p>\n\n\n\n<p>In this blog post, I\u2019ll guide you step-by-step on how to set up and host your static website using Amazon S3.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Use S3 for Static Website Hosting?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Cost-effective:<\/strong> You pay only for the storage and bandwidth you use.<\/li>\n\n\n\n<li><strong>Scalable:<\/strong> Handles any traffic without needing server management.<\/li>\n\n\n\n<li><strong>High availability:<\/strong> Designed for 99.999999999% durability.<\/li>\n\n\n\n<li><strong>Easy integration:<\/strong> Works seamlessly with other AWS services like CloudFront.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Create an S3 Bucket<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Log in to the AWS Management Console.<\/li>\n\n\n\n<li class=\"has-small-font-size\">Navigate to the <strong>S3<\/strong> service.<\/li>\n\n\n\n<li>Click <strong>Create bucket<\/strong>.<\/li>\n\n\n\n<li>Enter a unique bucket name (e.g., <code>my-static-site-bucket<\/code>).<\/li>\n\n\n\n<li>Choose the region closest to your audience.<\/li>\n\n\n\n<li>Leave other settings default or customize as needed.<\/li>\n\n\n\n<li>Click <strong>Create bucket<\/strong>.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Upload Your Website Files<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Upload your static files (index.html, styles.css, images, etc.) to your new bucket.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Configure the Bucket for Website Hosting<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Select your bucket.<\/li>\n\n\n\n<li>Go to the <strong>Properties<\/strong> tab.<\/li>\n\n\n\n<li>Click on <strong>Static website hosting<\/strong>.<\/li>\n\n\n\n<li>Enable <strong>Use this bucket to host a website<\/strong>.<\/li>\n\n\n\n<li>Enter <code>index.html<\/code> as the <strong>Index document<\/strong>.<\/li>\n\n\n\n<li>Optionally, add an <strong>Error document<\/strong> (e.g., <code>error.html<\/code>).<\/li>\n\n\n\n<li>Save changes.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Set Bucket Policy for Public Access<\/h2>\n\n\n\n<p>To make your website accessible to everyone, you need to update the bucket policy:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to the <strong>Permissions<\/strong> tab.<\/li>\n\n\n\n<li>Click <strong>Bucket Policy<\/strong>.<\/li>\n\n\n\n<li>Add this JSON policy (replace <code>YOUR_BUCKET_NAME<\/code>):<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">jsonCopyEdit<code>{\n  \"Version\":\"2012-10-17\",\n  \"Statement\":[{\n    \"Sid\":\"PublicReadGetObject\",\n    \"Effect\":\"Allow\",\n    \"Principal\": \"*\",\n    \"Action\":[\"s3:GetObject\"],\n    \"Resource\":[\"arn:aws:s3:::YOUR_BUCKET_NAME\/*\"]\n  }]\n}\n<\/code><\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Save the policy.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Access Your Website<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Your website is now available at the endpoint provided in the <strong>Static website hosting<\/strong> section, usually:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">cppCopyEdit<code>http:\/\/YOUR_BUCKET_NAME.s3-website-REGION.amazonaws.com\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Hosting a static website on Amazon S3 is simple, reliable, and cost-effective. Whether you\u2019re hosting a personal portfolio, blog, or project documentation, S3 can handle it with minimal setup.<\/p>\n\n\n\n<p>If you want to improve performance, you can integrate your S3 website with <strong>Amazon CloudFront<\/strong> for CDN and HTTPS support.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Amazon Simple Storage Service (S3) is a highly scalable, durable, and secure object storage service offered by AWS. One of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"left-sidebar","site-content-layout":"","ast-site-content-layout":"full-width-container","site-content-style":"unboxed","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[6],"tags":[11,13,15,14,12],"class_list":["post-24","post","type-post","status-publish","format-standard","hentry","category-s3","tag-amazon-s3","tag-aws-s3","tag-buckets","tag-static-website","tag-storage"],"_links":{"self":[{"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/posts\/24","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=24"}],"version-history":[{"count":2,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/posts\/24\/revisions"}],"predecessor-version":[{"id":67,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=\/wp\/v2\/posts\/24\/revisions\/67"}],"wp:attachment":[{"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=24"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=24"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mkcloudai.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=24"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}