Hosting a static website on Cloud Storage is one of the most common Associate Cloud Engineer exam scenarios for the service, and the steps are straightforward enough that the question is usually testing whether you know the order rather than anything subtle. This article covers the setup, the parts that trip people up, and the exam patterns.
It does not cover dynamic content, server-side rendering, or full Cloud CDN configuration at depth. Cloud Storage hosts static content only, which means HTML, CSS, JavaScript, images, and other files that do not require a server to generate them.
A static website is one made of fixed files. HTML, CSS, JavaScript, images. No server-side code. No database queries on each request. The browser downloads the files and renders them. Cloud Storage is well suited to this because it is built to serve files. Add a bucket, upload your files, configure a few settings, and you have a website.
The Associate Cloud Engineer exam calls this out directly. Cloud Storage is able to host static websites. That is the whole feature in one sentence.
The bucket name has to match your domain. If your site is at www.example.com, your bucket has to be named www.example.com. This is unusual compared to most cloud setups, where bucket names and domain names are independent. For Cloud Storage static hosting, they are linked.
You have to verify ownership of the domain through Google Search Console before you can create a bucket with that name. This prevents anyone from grabbing a bucket name that matches a domain they do not own.
The bucket has to allow public access. The standard way to do this is to grant the allUsers principal the Storage Object Viewer role on the bucket. This makes every object readable by anyone on the internet, which is what you want for a public website.
You configure an index page and an error page. The index page is what gets served when someone hits the root of your site. Conventionally, this is index.html. The error page is what gets served when someone requests a path that does not exist. Conventionally, this is 404.html or error.html.
gsutil web set -m index.html -e 404.html gs://www.example.com
You point your custom domain at the bucket using a CNAME record in DNS that points www.example.com to c.storage.googleapis.com. After the DNS propagates, the bucket starts serving as your website.
This is the part the Associate Cloud Engineer exam loves to test. Cloud Storage on its own only serves over HTTP for custom domains. To get HTTPS, you have to put a Cloud Load Balancer in front of the bucket. The load balancer terminates HTTPS and forwards requests to the bucket as the backend.
If you see a question about a static website on Cloud Storage that needs HTTPS, the answer is set up an HTTPS Cloud Load Balancer with the bucket as the backend. There is no way to do HTTPS on a custom domain with just the bucket.
This is the most common gotcha on this topic. Without HTTPS, the site works for testing, but most modern uses require it.
Worth flagging this as something the Associate Cloud Engineer exam might ask about. You can set Content-Type metadata on objects in Cloud Storage to control how the browser handles them. For example, setting the Content-Type to audio/mpeg on an MP3 file tells the browser to play it directly instead of prompting the user to download.
For static HTML, CSS, and JavaScript, the Content-Type is usually inferred correctly from the file extension. For media files or unusual file types, you may need to set it explicitly.
If you see a question about hosting a static website on GCP cheaply and at scale, the answer is Cloud Storage. App Engine is the wrong answer for this case because static-only sites do not need an application runtime, and Cloud Storage is cheaper.
If you see a question about a static website on Cloud Storage that needs HTTPS on a custom domain, the answer involves an HTTPS Cloud Load Balancer in front of the bucket. This is the most testable detail on this topic.
If you see a question about a 404 page or default page for a static website on Cloud Storage, the answer is the website configuration on the bucket, set with gsutil web set or in the console.
If you see a question about a static asset that should play in the browser instead of downloading, the answer is the Content-Type metadata on the object.
Bucket name matches the domain. Public read access via allUsers. Index and error pages configured. CNAME pointing to c.storage.googleapis.com. HTTPS requires a Cloud Load Balancer in front. The Associate Cloud Engineer exam tests this with questions about hosting cheaply, getting HTTPS to work, and configuring default and error pages.
My Associate Cloud Engineer course covers static website hosting in the Cloud Storage section alongside the Cloud Load Balancer setup the ACE exam expects.