Automate Cloud CDN setup with Terraform

Use the following examples to deploy sample backends with Cloud CDN enabled.

If you are new to using Terraform for Google Cloud, see Get started with Terraform.

Using a Cloud Storage bucket

The following sample configures Cloud CDN with a public Cloud Storage bucket. The sample also includes load balancing and caching configurations. The configurations can be modified, as required.

For details about each section of the sample, see Set up a backend bucket.

Using MIG and custom headers

You can use Terraform resources to bring up an external HTTP load balancer with a Cloud CDN backend service and custom request and response headers.

For information about the load balancer setup, see the primary setup guide.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.