← Previous

Host a Static Website on S3

Duration: 45 minutes

Learn how to host a static website using Amazon S3. You'll create a bucket, configure it for web hosting, and upload a simple webpage with an image. This lab demonstrates the power of serverless web hosting using AWS services.

⚠️ Important: This lab must be completed in the US West (Oregon) region us-west-2. Make sure your AWS Console is configured with this region before starting.

What you'll learn:

  1. Creating an S3 bucket with a unique name
  2. Configuring bucket policies for public access
  3. Enabling static website hosting
  4. Uploading and configuring web content
  5. Testing your static website

Step 1: Create an S3 Bucket

  1. In the AWS Console, navigate to S3 from the services menu
  2. Click Create bucket
  3. For Bucket name, enter a unique name (e.g., "my-website-lab-[YOUR-NAME]")
  4. For Region, select US West (Oregon) us-west-2
  5. Under Block Public Access settings, uncheck "Block all public access"
  6. Acknowledge the warning about making the bucket public
  7. Keep all other settings at their defaults
  8. Click Create bucket

Step 2: Configure Bucket Policy

  1. Go to the Permissions tab
  2. Under Bucket policy, click Edit
  3. Copy and paste the following policy (replace YOUR-BUCKET-NAME with your actual bucket name):
    { "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*" } ] }
  4. Click Save changes

Step 3: Enable Static Website Hosting

  1. Click on your newly created bucket
  2. Go to the Properties tab
  3. Scroll down to Static website hosting
  4. Click Edit
  5. Select Enable
  6. For Index document, enter "index.html"
  7. Click Save changes

Validation Checklist

  • ✓ Bucket is created in us-west-2 region
  • ✓ Static website hosting is enabled
  • ✓ Bucket policy allows public read access
  • ✓ index.html and webdev.jpg are uploaded
  • ✓ Website is accessible via the endpoint URL