Looking to host your portfolio, landing page, or simple website without paying for hosting? AWS S3 makes it incredibly easy and cost-effective to host static websites. In this complete step-by-step tutorial, you'll learn how to set up an S3 bucket, configure static website hosting, upload your HTML/CSS files, and make your site publicly accessible. Whether you're a beginner or a developer exploring serverless options, this guide will help you deploy a static site using AWS Free Tier—with zero backend required.
AWS S3 Bucket Tutorial: Step-by-Step Guide to Host a Static Website for Free
By: H.R.
08/07/2025
Learn how to host a static website on AWS S3 in minutes. This easy guide walks you through bucket creation, static website settings, file upload, and public access—all using the Free Tier.
AWS S3 Bucket Tutorial – Host a Static Website
Learn how to effortlessly deploy your static website globally with Amazon S3!
What is AWS S3 and Why Host Static Websites There?
Amazon Simple Storage Service (S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance. While it's primarily designed for storing data of any kind, S3 has a powerful feature that allows it to host static websites directly.
A static website is composed of fixed content like HTML pages, CSS stylesheets, JavaScript files, images, and videos. Unlike dynamic websites (which use server-side scripting like PHP, Python, or databases), static sites are served to the user's browser exactly as they are stored.
Why choose AWS S3 for your static website?
- Simplicity: No servers to manage, no operating systems to patch. S3 handles all the infrastructure.
- Scalability: S3 automatically scales to handle any amount of traffic, from a few visitors to millions, without you needing to provision resources.
- High Availability & Durability: Your website files are stored redundantly across multiple devices in multiple facilities within an AWS Region, offering 99.999999999% (11 nines) durability.
- Cost-Effective: You only pay for the storage you use, the data transferred, and the requests made. For small to medium static sites, this can be incredibly cheap, often falling within the generous AWS Free Tier limits.
- Integration: Seamlessly integrates with other AWS services like CloudFront (for CDN and HTTPS), Route 53 (for custom domains), and Lambda (for serverless functionality).
Prerequisites
- An AWS Account: Make sure you have an active AWS account.
- Your Static Website Files: Have your HTML, CSS, JavaScript, images, and other assets ready. Your main page should typically be named
index.html
. It's also good practice to have anerror.html
page.
Step-by-Step Guide: Hosting Your Static Website on S3
Step 1: Create an S3 Bucket
- Log in to the AWS Management Console.
- Search for "S3" in the search bar and navigate to the S3 Dashboard.
- Click the "Create bucket" button.
- Bucket name: Choose a globally unique name. If you plan to use a custom domain later (e.g.,
www.example.com
), it's highly recommended that your bucket name exactly matches your domain name (e.g.,www.example.com
). - AWS Region: Select a region geographically close to your target audience for lower latency.
- Object Ownership: Under "Object Ownership", select "ACLs enabled" and acknowledge the warning. This is crucial for granting public access later.
- Block Public Access settings for this bucket: IMPORTANT! You must uncheck "Block all public access". Acknowledge the warning that your bucket will become publicly accessible. For static website hosting, this is necessary.
- Leave other settings as default for now and click "Create bucket".
Step 2: Upload Your Website Files
Now that your bucket is ready, upload your website content.
- In the S3 console, click on the name of your newly created bucket.
- Click the "Upload" button.
- Drag and drop all your website files and folders (e.g.,
index.html
,styles.css
,js/main.js
,images/
folder,error.html
, etc.) into the upload area. Make sure your `index.html` file is in the root of the bucket, not inside a subfolder. - Click "Upload" at the bottom.
Step 3: Enable Static Website Hosting
This setting transforms your bucket into a web server.
- With your bucket selected, go to the "Properties" tab.
- Scroll down to the "Static website hosting" section and click "Edit".
- Select "Enable" for "Static website hosting".
- Choose "Host a static website".
- For "Index document", type
index.html
. This is the default page that loads when someone visits your site. - For "Error document" (optional but recommended), type
error.html
(if you have one). This page will be displayed for 404 errors. - Click "Save changes".
After saving, scroll back down to the "Static website hosting" section. You will now see a "Bucket website endpoint" URL (e.g., http://your-bucket-name.s3-website-your-region.amazonaws.com
). This is your website's URL!
Step 4: Configure Bucket Policy for Public Access
Even though you unchecked "Block all public access" earlier, you still need a bucket policy to explicitly allow public read access to your objects.
- With your bucket selected, go to the "Permissions" tab.
- Scroll down to the "Bucket policy" section and click "Edit".
- Paste the following JSON policy into the editor. Remember to replace
your-bucket-name
with the actual name of your S3 bucket!{ "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "*", "Action": ["s3:GetObject"], "Resource": ["arn:aws:s3:::your-bucket-name/*"] } ] }
This policy allows anyone (
"Principal": "*"
) to perform thes3:GetObject
action (read objects) on all objects (/*
) within your specified bucket. - Click "Save changes".
Step 5: Verify Your Website
Open a web browser and paste the "Bucket website endpoint" URL you got from Step 3. Your static website should now be live and accessible!
Advanced Considerations (For Pros & Future Learning)
- Custom Domain Names (Route 53): To use your own domain (e.g.,
example.com
instead of the S3 endpoint), you can configure AWS Route 53 (AWS's DNS service) to point your domain to your S3 bucket. Remember that if you want to use the naked domain (e.g., `example.com`), your bucket name must also match that (e.g., `example.com`). - HTTPS (SSL/TLS) with CloudFront: S3 static website endpoints support only HTTP. For HTTPS (which is essential for security and SEO), you'll need to use Amazon CloudFront, AWS's Content Delivery Network (CDN) service. CloudFront can distribute your website globally, cache content at edge locations for faster delivery, and provide SSL certificates.
- Deployment Automation: For continuous integration/continuous deployment (CI/CD), consider automating your website deployments using tools like AWS Amplify Console, AWS CodePipeline, or even simple scripts that use the AWS CLI.
- Redirects: S3 allows you to configure redirection rules for specific pages or for all requests.
- Access Logging: You can enable S3 access logging to record details of requests made to your bucket, useful for analytics and auditing.
Cost Implications
S3 hosting is generally very affordable. Costs are primarily based on:
- Storage: How much data you store (per GB per month).
- Data Transfer Out: Data transferred from S3 to the internet (per GB). There's usually a free tier for a certain amount of data transfer out per month.
- Requests: The number of GET (downloads) and PUT (uploads) requests made to your bucket.
For most small static websites, the costs can be as low as a few cents to a few dollars per month, especially if you stay within the AWS Free Tier limits (which typically includes 5GB of S3 Standard storage, 20,000 Get Requests, and 2,000 Put Requests per month).