Skip to main content

More Info:

Ensure Cloud CDN global user created backend services have failover policy enabled.

Risk Level

High

Address

Operational Maturity, Performance Efficiency, Reliability, Security

Compliance Standards

  • CIS GCP

Triage and Remediation

Remediation

Using Console

Below are concise, GCP‑Console–only steps to enable a failover policy on a Cloud CDN backend service (for a global external HTTP(S) load balancer).

1. Open the backend service for your CDN

  1. In the Google Cloud Console, go to:
    Navigation menu → Network services → Load balancing
  2. Make sure you’re in the right project and on the HTTP(S) Load Balancing tab.
  3. Find and click the global external HTTP(S) load balancer that uses Cloud CDN.
  4. On the load balancer detail page, go to the Backends tab.
  5. Under Backend services, click the backend service that has Cloud CDN enabled (name will be something like backend-service-...).

2. Edit the backend service

  1. On the backend service details page, click Edit at the top.
  2. Confirm Cloud CDN is enabled (toggle on). If not, enable it if required by your policy.

3. Configure failover on the backend(s)

Failover is configured at the backend entry inside the backend service:
  1. In the Backends section of the edit page, locate your primary backend (e.g., a MIG, NEG, or bucket backend).
  2. If you already have a backup backend listed:
    • Click the pencil (edit) icon next to the backup backend.
    • Check Enable failover (or Use as failover / similar wording depending on UI version).
    • Set the Failover ratio (e.g., 0.8), which defines when traffic starts failing over based on healthy capacity.
    • Click Save for that backend entry.
  3. If you do not have a backup backend configured yet:
    • Click Add backend.
    • Choose the backend type (e.g., instance group, NEG, or Cloud Storage bucket) you want to use as the failover target.
    • Set Capacity as appropriate (often 1.0 if it’s a full backup).
    • Check Use for failover only (or Enable failover depending on UI wording).
    • Optionally set Failover ratio.
    • Click Done or Save for that backend row.

4. Save the backend service

  1. After configuring the primary and failover backends, scroll to the bottom and click Save on the backend service.
  2. Wait for the configuration to propagate (usually a few minutes).

5. Verify the failover policy

  1. Go back to the Backends tab of the load balancer.
  2. Open the backend service again and verify:
    • You see both primary and failover backends.
    • The failover flag is turned on for the backup backend.
    • The Failover ratio is set as required by your policy.
This enables a failover policy for your global Cloud CDN–fronted backend service using the GCP Console.
Below is how to enable / configure the failover policy on a global backend service used by Cloud CDN using gcloud.

1. Identify the affected backend service(s)

Look for:
  • cdnPolicy → confirms Cloud CDN is enabled
  • backends → ensure you have at least one failover backend (failover: true) defined, or plan to add one
  • failoverPolicy → will be missing or incorrectly set today

2. Ensure primary and failover backends exist

If you don’t yet have a failover backend configured, you must add one first (same backend service, different backend entry with failover: true):
Adjust flags for your resource type (e.g. --network-endpoint-group / --global-network-endpoint-group instead of --instance-group if using NEGs).

3. Enable / set the failover policy

Use --failover-policy on the backend service:
  • disableConnectionDrainOnFailover=true
    New connections switch immediately to the failover backend (no draining delay).
  • dropTrafficIfUnhealthy=true
    If both primary and failover backends are unhealthy, traffic is dropped instead of being sent to unhealthy backends.
If you want different behavior, adjust the values:

4. Verify the configuration

You should see something like:
That completes enabling the failover policy for a global Cloud CDN backend service via gcloud.
Below is a concise, step‑by‑step way to enable failover policy for global Cloud CDN backend services in GCP using Python.

1. Prerequisites

  1. Install the Python client:
  2. Authenticate (one of):
  3. Ensure your account has roles such as:
    • roles/compute.admin (or equivalent permissions on backend services).

2. What You Need to Change

For global HTTP(S)/SSL/TCP proxy backend services, the BackendService resource supports:
Your goal is to set failoverPolicy for each Cloud CDN backend service that doesn’t have it.
Note: This only applies to global backend services (not regional), typically used by global HTTP(S) Load Balancers.

3. Python Code – Enable Failover Policy for a Single Backend Service


4. Optional: Automatically Fix All Global CDN Backend Services

To automatically remediate all global backend services with Cloud CDN enabled and no failoverPolicy, you can extend the script:

5. Validate

  1. In the Cloud Console:
    • Network services → Cloud CDN → Backend services
    • Open each backend service and check the Failover policy section.
  2. Or via gcloud:
If you share the exact policy your security tool expects (e.g., required failoverRatio), I can adjust the Python example to match it precisely.
This change does not normally force replacement of the backend service; it is applied in-place by updating the existing google_compute_backend_service.After you add or update this block, terraform plan should show an in-place update (~) to google_compute_backend_service.CDN_BACKEND_SERVICE with a new or changed failover_policy block and (if you added the secondary backend) the additional backend entry.

Additional Reading: