How to Host a Website on Amazon S3

Pooja RautPooja Raut
2 min read

Hosting a website on Amazon S3 is a great way to share your site with the world. It’s simple, cost-effective, and scalable. Here’s a step-by-step guide written in easy language to help you host your website on Amazon S3.

1. What is Amazon S3?

Amazon S3 (Simple Storage Service) is a service by AWS that allows you to store files. You can use it to host your static website. A static website means the content doesn’t change dynamically (like HTML, CSS, and JavaScript files).

Steps to Host Your Website:

Step 1: Log in to AWS

  1. Go to the AWS Management Console.

  2. Sign in with your credentials. If you don’t have an account, create one—it’s free to start.

Step 2: Create a Bucket

  1. Search for S3 in the search bar.

  2. Click on "Create Bucket."

    • Bucket Name: Give your bucket a unique name (e.g., mywebsite123).

    • Region: Choose a nearby region.

  3. Uncheck "Block all public access" so your website is visible.

  4. Click "Create Bucket.”

Step 3: Upload Your Website Files

  1. Click on your bucket name.

  2. Go to the "Upload" section.

  3. Add your website files (e.g., index.html, styles.css, images).

  4. Click "Upload" to save them in the bucket.

Step 4: Configure Your Bucket for Hosting

  1. Go to the "Properties" tab in your bucket.

  2. Scroll down to "Static website hosting" and click "Edit."

  3. Choose "Enable" for static website hosting.

  4. Set the index document (e.g., index.html).

    • If you have an error page, you can set it here (e.g., 404.html).
  5. Save the changes.

Step 5: Make Your Files Public

  1. Go to the "Permissions" tab.

  2. Edit the Bucket Policy:
    Copy and paste this policy (replace mywebsite123 with your bucket name):

     jsonCopy code{
       "Version": "2012-10-17",
       "Statement": [
         {
           "Effect": "Allow",
           "Principal": "*",
           "Action": "s3:GetObject",
           "Resource": "arn:aws:s3:::mywebsite123/*"
         }
       ]
     }
    
  3. Save it. This allows people to access your website.

Step 6: Test Your Website

  1. Go back to the "Properties" tab and find the Bucket Website Endpoint.

  2. Click the link, and your website should open!

What’s Next?

  • Custom Domain: You can link your own domain (e.g., www.mywebsite.com) by configuring Route 53 or other DNS services.

  • HTTPS: Use Amazon CloudFront to add SSL for a secure connection.

Hosting your site on Amazon S3 is that simple. No complex setup, no big bills—just your website, ready to go live! 🚀 !!

Happy coding!! 🌻

0
Subscribe to my newsletter

Read articles from Pooja Raut directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Pooja Raut
Pooja Raut

👨‍💻 BE Student | Enthusiastic about DevOps and Full-Stack Development | Passionate about Technology and Innovation | Exploring the world of development and operations to create seamless software solutions.