Static Website Hosting
This reference document outlines the configuration mapping and architecture recommendation for Cloud Storage buckets configured to host static websites.
Description
The user is deploying a static website (HTML, CSS, JavaScript, media assets) directly to Cloud Storage. The site needs to be publicly accessible, support custom domain mapping, scale automatically for viral traffic spikes, and serve assets with low latency without backend servers.
Bucket Configuration Plan Mapping
The following table maps the Static Website Hosting use case to specific Cloud Storage features and details their recommendation status.
| Feature Group | Cloud Storage Feature / Setting | Status | Recommendations & Implementation Details | Documentation Link |
|---|---|---|---|---|
| Core | Storage Class | Highly Recommended | Standard Storage Class.Required for web serving to ensure immediate, low-latency, and high-throughput asset delivery. Colder tiers must be avoided due to retrieval fees. | Storage Classes |
| **Bucket Type** | Highly Recommended | **Multi-Regional (MR)**. Distributes website content globally to ensure high availability and low latency for diverse user locations. | [Locations](https://cloud.google.com/storage/docs/locations)
Serving | CORS | Highly Recommended | Configure CORS if the site loads assets from other origins, or if assets from this bucket are queried by external frontends. | CORS
| Website Settings | Required | Configure Website Configuration. Set the mainPageSuffix (e.g. index.html) and notFoundPage (e.g. 404.html) to handle root requests and errors. | Hosting Static Website
Security | Uniform Bucket-Level Access (UBLA) | Required | Must be enabled. Standardizes IAM permissions across the bucket. | Uniform Bucket-Level Access
| Public Access Prevention (PAP) | Disabled (Exception) | Must be set to "inherited" / Disabled. Public access must be allowed to serve web traffic. Grant roles/storage.objectViewer to allUsers to make assets publicly accessible. | Public Access PreventionMake Bucket Public
| Soft Delete | Good to Have | Enabled as a critical rollback mechanism. Helps restore website files quickly if deleted by broken build/deploy scripts. | Soft Delete
| Object Versioning | Good to Have | Alternative to Soft Delete. Allows rolling back bad deployments to a prior known good state, but requires OLM to prune history. | Object Versioning
| IP Filtering | Optional | Use only if you must limit access to specific IP ranges (including countries or corporate networks, e.g. staging site). | Bucket IP Filtering
Cost | Object Lifecycle Management (OLM) | Highly Recommended | If Versioning is enabled, set lifecycle rules to prune non-current versions (e.g., after 30 days) to prevent old builds from increasing storage bills. Recommend standard OLM rule:Transition to ARCHIVE after 365 days. | Lifecycle Management
Management | Labels & Tagging | Good to Have | Apply environment tags (e.g., {"environment": "production"}). | Bucket Labels
Transfers | Storage Transfer Service (STS) | Good to Have | Replicate site assets closer to compute regions using STS. | Storage Transfer Service
Monitoring | Cloud Logging | Highly Recommended | Enable logs to analyze web usage stats, referral paths, and user-agent data. | Cloud Audit Logging
| Cloud Monitoring | Highly Recommended | Setup alerts on public egress, total operations, and error rates (e.g., 404/503). | Cloud Monitoring
| Pub/Sub Notifications | Good to Have | Trigger downstream workflows (such as clearing a CDN cache) whenever index.html or other assets are updated. | Pub/Sub Notifications