DEV Community

Cover image for Hands-On Guide: Configuring a Static Website on Amazon S3
Seyi Lufadeju
Seyi Lufadeju

Posted on

Hands-On Guide: Configuring a Static Website on Amazon S3

Introduction

Static websites, composed of HTML, CSS, JavaScript, and media files, are ideal for portfolios, blogs, or landing pages. Amazon S3 offers a cost-effective, scalable solution to host static sites without managing servers. This guide walks you through hosting a sample website on S3, covering bucket creation, permissions, and testing. By the end, you’ll have a live site accessible via an S3 endpoint URL.


Step-by-Step Guide

  1. Create an S3 Bucket Step 1.1: Log into the AWS Management Console, navigate to S3, and click Create bucket.
  • Step 1.2: Name your bucket (e.g., my-static-website-123). Ensure the name is globally unique.

Image description

  • Step 1.3: Select a region (e.g., us-east-1).
  • Step 1.4: Take the default settings
  • Step 1.5: Click Create bucket.

Image description


2. Enable Static Website Hosting

  • Step 2.1: Navigate to the Properties tab.

Image description

  • Step 2.2: Scroll to Static website hosting and click Edit.

Image description

  • Step 2.3: Select Enable, then specify: Index document: index.html Error document: 404.html

Image description

Step 2.4: Click Save.


3. Configure Bucket Permissions

  • Step 3.1: Go to the bucket’s Permissions tab.
  • step 3.2: Click Edit on Block public access (bucket settings) to unblock public access

Image description

Image description

  • Step 3.3: Under Bucket Policy, paste this JSON (replace my-static-website-123 with your bucket name):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicReadGetObject",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::my-static-website-123/*"
    }
  ]
}


Enter fullscreen mode Exit fullscreen mode

Image description

Step 3.3: Click Save.


4. Upload Sample Website Files

Image description

- Click on upload after adding the Files and Folders

Image description

- You should have a successful notification after uploading

Image description


5. Test the Website

Image description

Image description


Conclusion
I’ve successfully hosted a static website on Amazon S3! This setup is ideal for low-cost, high-availability sites.

By leveraging S3’s simplicity and scalability, you can focus on content creation while AWS handles infrastructure. Explore advanced features like versioning for backups or S3 events for serverless workflows to further optimize your site.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay