How to Host a Static Website on Amazon S3 (Step-by-Step Guide)

๐Ÿ”ง WHAT YOU NEED

An AWS account

Basic knowledge of HTML/CSS/JS

A static website folder ready for upload

---

โœ… Step 1: Create an S3 Bucket

1. Log in to your AWS Management Console.

2. Navigate to S3 from the Services menu.

3. Click "Create bucket".

4. Give your bucket a unique name (e.g., my-website-bucket).

5. Choose a region (close to your users).

6. Uncheck "Block all public access" โ€“ you'll need to make the files publicly accessible.

7. Acknowledge the warning and click Create bucket.

\> ๐Ÿ’ก Tip: The bucket name should match your domain name if you're using a custom domain (e.g., example.com).

---

๐Ÿ“ Step 2: Upload Your Website Files

1. Click on your newly created bucket.

2. Go to the Objects tab.

3. Click Upload > Add files/folder.

4. Select your websiteโ€™s files (e.g., index.html, styles.css, script.js).

5. Click Upload.

---

๐ŸŒ Step 3: Enable Static Website Hosting

1. In your bucket, go to the Properties tab.

2. Scroll to Static website hosting.

3. Click Edit and enable it.

4. Choose "Host a static website".

5. Enter the index document (e.g., index.html).

6. (Optional) Enter an error document (e.g., 404.html).

7. Save changes.

You'll now see a website endpoint URL โ€“ this is the public link to your site!

---

๐Ÿ” Step 4: Make Your Files Public

By default, S3 keeps your files private. To allow public access:

1. Go to the Permissions tab of your bucket.

2. Scroll to Bucket policy and click Edit.

3. Paste the following JSON policy (replace your-bucket-name):

{

"Version": "2012-10-17",

"Statement": [

{

"Sid": "PublicReadGetObject",

"Effect": "Allow",

"Principal": "*",

"Action": "s3:GetObject",

"Resource

": "arn:aws:s3:::your-bucket-name/*"

}

]

}

4. Save changes.

Now your files are accessible via the web.

0
Subscribe to my newsletter

Read articles from NDUKA DIVINE CHIBUIKE directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

NDUKA DIVINE CHIBUIKE
NDUKA DIVINE CHIBUIKE