Using Terraform to configure a flexible load balancer for Cloud Run
Note
The code for this section can be found in the chap07/main
directory in this book’s GitHub repository.
In the previous chapter, we provisioned a global load balancer using Terraform. In this architecture, we will expand on it by making it more flexible – all static assets will be served from Cloud Storage, whereas all dynamic traffic will be served from Cloud Run.
Google Cloud Storage is a very cost-effective way to host static assets for web applications, such as images, CSS files, and static HTML pages. Two configurations are required to use a bucket as a website. First, we need to assign specialty pages such as the default page and notFoundpage
(https://cloud.google.com/storage/docs/hosting-static-website#specialty-pages).
Second, as our website is open to the public, we need to make the bucket publicly accessible by using the google_storage_bucket_iam_binding
resource. We will also...