Static Website Hosting on GCP

Serverless static website hosting using Google Cloud Storage

Google Cloud StorageIAM

Overview

A deployment demonstrating how to host a static website on Google Cloud Storage with proper IAM configuration, public access controls, and custom domain mapping — a cost-effective, serverless alternative to traditional hosting.

Problem Statement

Hosting static websites traditionally requires provisioning and managing web servers, incurring overhead for infrastructure that simply needs to serve files. A simpler, more cost-effective, and maintenance-free solution is needed for static content delivery.

Key Features

  • Static website hosting directly from a Cloud Storage bucket
  • IAM-controlled public access with allUsers read permissions
  • Custom index page and 404 error page configuration
  • Cost-efficient serverless hosting with no compute required
  • Scalable to any traffic level without infrastructure changes

Architecture

1Cloud Storage bucket configured as a website endpoint
2Bucket-level IAM policy grants allUsers objectViewer for public access
3Website configuration sets index.html as the main page and 404.html for errors
4Static assets (HTML, CSS, JS, images) stored as objects in the bucket

Challenges & Solutions

Correctly configuring IAM permissions to make the bucket publicly readable without exposing bucket metadata or write access.

Applied the `roles/storage.objectViewer` IAM binding to `allUsers` at the bucket level, which grants read-only access to objects without any administrative permissions.

What I Learned

  • Cloud Storage bucket configuration for static website hosting
  • IAM policy design for controlled public access to GCP resources
  • The trade-offs between Cloud Storage hosting and compute-based hosting for static content