Lab: Host a Static Portfolio on S3

Acadestine

Learning Objectives
    • Create and configure a globally unique Amazon S3 bucket dedicated to web hosting.
    • Enable Static Website Hosting on S3 and designate index and error documents.
    • Draft and apply a public bucket policy to allow global HTTP read access to portfolio assets.

Prerequisites: Preparing Your Launchpad

Now that you understand how to store and query data in the cloud, it is time to build the user-facing window to your application: the frontend. Before launching any workload into production, you must master two foundational prerequisites: navigating the cloud environment via the AWS Management Console and organizing your web files into a clean static asset structure.


Navigating the AWS Management Console

The AWS Management Console is a web-based graphical interface used to manage cloud resources. While automated tools and APIs handle production deployments, the console is your primary command center for visualizing configurations, checking system status, and managing services.

SCREENSHOT REQUIRED: The AWS Management Console global navigation bar highlighting the Unified Search bar, Services menu, and Region Selector dropdown in the top-right corner

When logging into the console, your primary interaction points live in the top navigation header:

  • Unified Search Bar: Located at the top left, this allows you to quickly find any AWS service, feature, documentation, or marketplace product by typing its name (for example, searching for S3 or IAM).
  • Services Menu: Marked by an icon of nine dots next to the search bar, this dropdown organizes all AWS offerings into logical categories such as Compute, Storage, and Databases.
  • Region Selector: Positioned in the top right header, this menu determines which geographical AWS Region your console is currently viewing (such as us-east-1 for N. Virginia or eu-west-1 for Ireland). Always verify your active Region before creating resources, as AWS services and data exist isolated within specific geographical areas unless globally configured.
  • Account Menu: Displays your Account ID and current identity role, providing access to account billing settings and sign-out controls.

Structuring Your Static HTML Assets

A static website consists of pre-built files written in HTML, CSS, JavaScript, and media formats that are delivered directly to the user's browser without requiring server-side rendering code like Python, Node.js, or PHP.

To host a website cleanly in the cloud, your local project directory must follow a standardized layout. A predictable file hierarchy ensures your cloud web server can route incoming traffic to the correct assets without broken links.

Here is the required baseline folder structure for your local web portfolio:

text my-portfolio/ ├── index.html ├── error.html ├── css/ │ └── style.css ├── js/ │ └── main.js └── images/ └── profile.jpg

Core Components Breakdown

  1. index.html (The Entry Point): This file is the default home page of your application. When a user requests your domain without specifying a path (e.g., https://example.com), web servers automatically attempt to load index.html. It serves as the primary structural frame of your website.

  2. error.html (The Fallback Page): This file acts as your custom HTTP 404 response page. If a client attempts to navigate to a URL that does not exist in your file system, the web server will deliver error.html instead of displaying a generic browser error.

  3. Subdirectories (css/, js/, images/): Organizing supporting files into discrete subdirectories keeps your root directory clean and simplifies permissions management when transferring files to cloud storage.

The Critical Rule of Relative Pathing

When developing web assets intended for cloud deployment, you must use relative file paths instead of absolute file paths.

An absolute path references a fixed location on a local file system (for example, /Users/alex/Desktop/my-portfolio/css/style.css or C:\Documents\my-portfolio\css\style.css). If you hardcode absolute paths, your website will instantly break when uploaded to the cloud because those local disk paths do not exist in a cloud environment.

Instead, use relative paths that reference file locations relative to the directory containing index.html:

html

By ensuring your files use relative paths and reside within a structured root directory, your web project is now fully prepared to take flight in the cloud.

Lab Goal: Instant Cloud Web Presence

By ensuring your files use relative paths and reside within a structured root directory, your web project is now fully prepared to take flight in the cloud. But before configuring resources in the console, let's step back and understand the architecture powering your launch: Amazon S3 (Simple Storage Service) and the paradigm of serverless static website hosting.

Storage Buckets: From Digital Locker to Web Host

Think of a standard cloud storage container known in AWS as a bucket as a massive, organized digital filing cabinet. Typically, you upload files like backup documents, images, or raw data into a bucket for secure storage, where they sit out of public view.

However, Amazon S3 possesses a unique built-in capability: with a simple configuration toggle, you can transform a passive storage bucket into an active, globally accessible web host.

Instead of requiring a dedicated virtual server running around the clock to display your portfolio, Amazon S3 listens for standard web requests and delivers your index.html, styling sheets, and media assets straight to your visitors' browsers. Your bucket stops acting like a private digital locker and starts functioning like a high-performance publishing platform.

The Magic of Serverless Web Hosting

When you host a static website using Amazon S3, you are adopting a serverless architecture. This does not mean physical servers aren't involved behind the scenes; it means AWS completely manages the underlying hardware and operating systems so you never have to provision, manage, or monitor a server yourself.

Deploying web assets directly to a storage bucket unlocks enterprise-grade capabilities without enterprise complexity.

  • Zero Infrastructure Management: You never have to install security updates, manage operating system patches, or restart crashed services.
  • Automatic Elastic Scaling: Whether 5 recruiters visit your portfolio site today or 50,000 visitors arrive at once from a trending link, Amazon S3 seamlessly absorbs the traffic spikes without performance loss.
  • Built-in Redundancy: AWS stores your files redundantly across multiple physical locations, designing Amazon S3 for 99.999999999% (11 9's) of data durability.
  • Minimal Operating Cost: Instead of paying a recurring monthly fee to keep a virtual machine running constantly, you pay pennies based strictly on the storage you consume and data sent over the network.
Hosting Aspect Traditional Server Model Serverless Amazon S3 Hosting
Maintenance Manual updates, OS patching, server reboots Zero infrastructure maintenance required
Scaling Manual resizing or complex auto-scaling policies Instantaneous, automatic traffic handling
Cost Model Hourly or fixed monthly server charges Pay-per-use (storage and data transfer)
Setup Focus Operating systems, web server software, firewall rules Direct file uploads and permissions setup

By turning your local web assets into a serverless Amazon S3 deployment, you obtain a resilient, globally available cloud footprint in minutes. With this conceptual foundation established, let me show you how web traffic actually reaches your stored assets.

Architecture: Serving Web Traffic via S3

With this conceptual foundation established, let me show you how web traffic actually reaches your stored assets.

To host a website on Amazon S3, your storage container needs to transform from a private file repository into a public-facing web server. This transformation relies on two core architectural components: a specialized S3 website endpoint URL and a configured public read access pattern.


Anatomy of an S3 Website Endpoint

When you store standard files in AWS, Amazon S3 exposes a REST API endpoint designed for programmatic file management. However, when you enable static website hosting, AWS generates a specialized web endpoint optimized specifically for browser traffic.

Unlike standard S3 API endpoints, S3 website endpoints are tailored to act like conventional web servers.

The structure of an S3 website endpoint URL follows a predictable, structured pattern:

http://<bucket-name>.s3-website.<region>.amazonaws.com

Let's break down each element of this URL architecture:

URL Component Example Description
Bucket Name my-portfolio-bucket The globally unique name of your Amazon S3 bucket.
Endpoint Marker s3-website Signals to AWS that this request should be handled by S3's web engine rather than its REST API.
AWS Region us-east-1 The specific AWS geographic region hosting your bucket hardware.
Domain Host amazonaws.com The root Amazon Web Services domain.

Understanding the distinction between a standard S3 API URL and a website endpoint URL is critical:

  • Standard S3 REST Endpoint (s3.amazonaws.com): Expects authenticated API calls, enforces strict bucket permissions, and downloads files as raw attachments rather than rendering them in a browser.
  • S3 Website Endpoint (s3-website.amazonaws.com): Accepts standard web traffic, automatically serves designated web documents like index.html, and allows browsers to render web pages directly.

The Public Read Access Pattern

Once a user enters your S3 website endpoint URL into a web browser, Amazon S3 processes the incoming network request through a specific security evaluation path.

Because Amazon S3 buckets are secure and private by default, you must explicitly grant public read access so anonymous web traffic can view your site.

Here is how a web request flows through the S3 architectural pattern:

  1. Client HTTP Request: A user's browser sends an unauthenticated HTTP GET request across the internet to your S3 website endpoint URL.
  2. Endpoint Reception: The S3 website endpoint intercepts the request and identifies which object (such as index.html or styles.css) the browser is asking to view.
  3. Security Access Evaluation: Amazon S3 checks its internal access controls to evaluate if anonymous users are allowed to read objects in that bucket.
  4. Content Delivery: If the public read pattern is authorized, Amazon S3 returns an HTTP 200 OK status along with the requested web files, allowing the user's browser to render your portfolio live on screen.

If the public read pattern is missing or blocked, Amazon S3 rejects the incoming request at the boundary, preventing unauthorized internet users from viewing your files.

Now that you understand how S3 formats web addresses and routes incoming traffic, you are ready to assemble these pieces inside the AWS Cloud.

Deployment: Building Your S3 Web Host

Now that you understand how S3 formats web addresses and routes incoming traffic, you are ready to assemble these pieces inside the AWS Cloud. We will move step-by-step through creating the bucket, turning on hosting capabilities, and opening the door for incoming HTTP traffic using a JSON policy.


Step 1: Create the Globally Unique S3 Bucket

Every S3 bucket name must be globally unique across all AWS accounts worldwide. Because S3 bucket names form the prefix of standard domain names, no two AWS users can share the same bucket name in any region.

To create your bucket in the AWS Management Console:

  • Navigate to the S3 service dashboard and click Create bucket.
  • In the Bucket name field, enter a unique identifier (for example, my-portfolio-site- followed by your initials and a random number).
  • Select your target AWS Region (such as us-east-1 for US East / N. Virginia).
  • Scroll to Block Public Access settings for this bucket. Uncheck Block all public access.

AWS enables Block Public Access safeguards by default to prevent accidental data leaks. Because our explicit goal is to serve public static web pages to visitors worldwide, you must acknowledge the warning checkbox confirming that the bucket will become public. Leave all other security settings at their default positions and click Create bucket.


Step 2: Enable Static Website Hosting

By default, an S3 bucket operates like a private cloud storage vault rather than a web server. To instruct S3 to accept web requests and serve documents, we must enable its native static hosting engine.

  • Click on your newly created bucket name to enter its management dashboard.
  • Click on the Properties tab at the top of the interface.
  • Scroll to the very bottom of the page to locate the Static website hosting panel and click Edit.
  • Select Enable.
  • In the Index document field, type index.html. This defines the default landing page loaded when a visitor requests your root URL.
  • In the Error document field, type error.html. This defines the custom page displayed when a visitor requests a path that does not exist.
  • Click Save changes.

SCREENSHOT REQUIRED: AWS Console S3 Properties tab highlighting the Static website hosting configuration pane with index.html typed into the Index document field and Enable selected.

Once saved, S3 generates your custom Bucket website endpoint URL at the bottom of the Static website hosting panel. However, navigating to this URL right now will result in an error because we have not yet granted explicit public read permissions to the files inside.


Step 3: Configure the Public Bucket Policy

Unchecking "Block Public Access" unlocked the safety switch on the bucket, but you must attach an Access Control JSON policy to grant public read permissions to incoming website visitors.

A bucket policy is a JSON-formatted security document that defines precisely who can perform which actions on your bucket resources.

To attach the public policy:

  • Navigate to the Permissions tab of your bucket.
  • Locate the Bucket policy section and click Edit.
  • Paste the following JSON block into the policy editor editor window:

json { "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/" } ] }

Replace YOUR-BUCKET-NAME inside the Resource string with the exact name of your bucket.

Let's break down the structural mechanics of this JSON policy:

JSON Key Value Technical Function
Effect "Allow" Explicitly permits the defined action rather than denying it.
Principal "*" Acts as a wildcard representing any anonymous user on the internet.
Action "s3:GetObject" Restricts public access exclusively to reading/downloading file objects.
Resource "arn:aws:s3:::YOUR-BUCKET-NAME/*" Applies the permission to every file inside the bucket via the trailing /*.

Click Save changes. Your S3 bucket is now fully deployed, configured as a web server, and permissioned to serve static content to global web traffic. With your S3 bucket created, hosting enabled, and public access policy applied, your cloud web host is fully configured and ready for live verification.

Validation: Verifying Your Live Portfolio

With your S3 bucket created, hosting enabled, and public access policy applied, your cloud web host is fully configured and ready for live verification. Now comes the moment of truth: accessing your website from the open internet and inspecting the raw HTTP network communication between your browser and AWS infrastructure.

Step 1: Retrieving Your S3 Website Endpoint URL

To view your portfolio, you must fetch the unique network endpoint generated by Amazon S3 when you enabled static website hosting. This URL is distinct from standard S3 REST API endpoints; it is specifically designed to act as a public web server endpoint.

To locate your endpoint in the AWS Management Console: 1. Open the Amazon S3 console and click on your specific portfolio bucket name. 2. Select the Properties tab from the top navigation menu. 3. Scroll to the very bottom of the page to the Static website hosting card. 4. Locate the Bucket website endpoint field and click the copy icon next to the link.

Your S3 endpoint URL follows a standardized structure: http://<bucket-name>.s3-website.<region>.amazonaws.com. Notice that this endpoint begins with http:// and includes the s3-website routing marker in the host domain. Paste this URL into a new browser tab and press Enter. Your rendered index.html web page should immediately load on the screen.

Step 2: Verifying the HTTP 200 OK Network Status

While seeing your web page visually render is exciting, cloud engineers always verify operational success at the network protocol layer. Confirming an explicit 200 OK HTTP status code guarantees that Amazon S3 located your designated index file and delivered the HTML payload without issues.

To perform a network validation using your browser's built-in Developer Tools: * Open Developer Tools: Right-click anywhere on your rendered webpage and select Inspect, or press F12 (Cmd + Option + I on macOS). * Navigate to the Network Panel: Click on the Network tab at the top of the Developer Tools panel. * Trigger a Page Refresh: Reload the page (Ctrl + R or Cmd + R) to capture the HTTP transactions in real time. * Inspect the Primary Asset: Click on the top line item in the network log, which represents your initial document request. * Verify Status Code: Locate the Status Code field in the Headers detail panel.

SCREENSHOT REQUIRED: Browser Developer Tools open to the Network tab, highlighting a selected index.html request showing a Status Code of 200 OK and Response Headers from Amazon S3.

When your S3 endpoint returns a 200 OK code, it confirms three key technical milestones under the hood: * Domain Resolution: Your browser successfully resolved the S3 website endpoint hostname to an active AWS IP address. * Server Reachability: The HTTP GET request successfully reached the storage infrastructure hosting your bucket. * Payload Delivery: S3 evaluated your bucket policy, retrieved the designated index.html file, and returned the file contents to your browser.

HTTP Status Code Status Name Network Verification Meaning
200 OK Standard HTTP success. S3 found the requested asset and streamed the payload back to the browser.

With a clean 200 OK status code confirmed in your browser, your static portfolio is officially live and reachable across the globe!

Troubleshooting: Fixing Common Hosting Errors

With a clean 200 OK status code confirmed in your browser, your static portfolio is officially live and reachable across the globe! However, even senior cloud engineers encounter unexpected roadblocks during deployments.

When an S3 static website fails to load, it almost always boils down to one of two standard HTTP error codes: 403 Forbidden (Access Denied) or 404 Not Found. Learning how to quickly diagnose and fix these errors is a fundamental skill for operating in AWS.


Resolving HTTP 403 Forbidden (Access Denied) Errors

An HTTP 403 Forbidden error indicates that Amazon S3 received your web request, but intentionally blocked access due to restrictive permissions. Because AWS defaults to a "security-first" posture, S3 buckets lock down all public access until you explicitly grant read permissions.

SCREENSHOT REQUIRED: AWS S3 Console showing the Block Public Access toggle set to Off and a valid S3 Bucket Policy in the JSON editor.

If you hit a 403 Access Denied screen when testing your website endpoint, step through these fixes:

  • Check the Block Public Access settings: Navigate to the Permissions tab of your bucket. Ensure that Block all public access is turned OFF. If this master switch remains enabled, it overrides any public policies you write.
  • Verify the Bucket Policy syntax: Inspect your JSON bucket policy. Confirm that the "Effect" key is set to "Allow", the "Principal" is set to "*" (allowing anyone), and the "Action" is set to "s3:GetObject".
  • Check for the trailing wildcard (/*): The single most common bucket policy mistake is omitting the trailing /* on your resource ARN. Writing "Resource": "arn:aws:s3:::my-bucket" grants permissions to the bucket container itself, not the HTML files inside it. You must specify "Resource": "arn:aws:s3:::my-bucket/*" to grant read access to all nested files.

Resolving HTTP 404 Not Found Errors

While 403 errors are permission problems, an HTTP 404 Not Found error means S3 cannot locate the file requested by your web browser. The server is accessible and public, but the requested object key does not exist at that specific path.

S3 object keys are strictly case-sensitive, meaning index.html and Index.html are treated as two entirely different files by AWS.

To resolve a 404 Not Found error, investigate the following root causes:

  • Index document misconfiguration: Under the Properties tab in the S3 Console, scroll down to Static website hosting. Ensure the value entered in the Index document field matches your actual file name character-for-character.
  • File path and folder structure: Verify that your index.html file sits directly in the root level of your S3 bucket rather than inside a subfolder like /src/index.html or /public/index.html.
  • Filename casing and typos: Double-check your uploaded files against your local development environment. A simple typo, such as naming your file index.htm instead of index.html, will trigger a 404 error on the root URL endpoint.

Comparing Common S3 Web Hosting Errors

Error Code HTTP Status Root Cause Primary Fix
403 Forbidden Access Denied Bucket policy is missing, malformed, or Block Public Access is ON. Turn off Block Public Access and attach an s3:GetObject policy with a /* resource wildcard.
404 Not Found Missing Object S3 cannot find the requested key, or the file is located in a subfolder. Verify exact case-sensitivity, check root directory uploads, and confirm index document configuration.

By mastering these two diagnostic paths, you can instantly recover from broken deployments and ensure your static web applications remain highly available to users worldwide.

Previous Next Lesson