More Info:
Ensure Cloud CDN global user created backend services have failover policy enabled.Risk Level
HighAddress
Operational Maturity, Performance Efficiency, Reliability, SecurityCompliance Standards
- CIS GCP
Triage and Remediation
- Remediation
Remediation
Using Console
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
- In the Google Cloud Console, go to:
Navigation menu → Network services → Load balancing - Make sure you’re in the right project and on the HTTP(S) Load Balancing tab.
- Find and click the global external HTTP(S) load balancer that uses Cloud CDN.
- On the load balancer detail page, go to the Backends tab.
- Under Backend services, click the backend service that has Cloud CDN enabled (name will be something like
backend-service-...).
2. Edit the backend service
- On the backend service details page, click Edit at the top.
- 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:- In the Backends section of the edit page, locate your primary backend (e.g., a MIG, NEG, or bucket backend).
- 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.
- 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.0if 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
- After configuring the primary and failover backends, scroll to the bottom and click Save on the backend service.
- Wait for the configuration to propagate (usually a few minutes).
5. Verify the failover policy
- Go back to the Backends tab of the load balancer.
- 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.
Using CLI
Using CLI
Below is how to enable / configure the failover policy on a global backend service used by Cloud CDN using
Look for:
Adjust flags for your resource type (e.g.
You should see something like:That completes enabling the failover policy for a global Cloud CDN backend service via
gcloud.1. Identify the affected backend service(s)
cdnPolicy→ confirms Cloud CDN is enabledbackends→ ensure you have at least one failover backend (failover: true) defined, or plan to add onefailoverPolicy→ 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 withfailover: true):--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.
4. Verify the configuration
gcloud.Using Python
Using Python
Below is a concise, step‑by‑step way to enable failover policy for global Cloud CDN backend services in GCP using Python.
Your goal is to set
1. Prerequisites
- Install the Python client:
- Authenticate (one of):
- 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, theBackendService resource supports: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
- In the Cloud Console:
- Network services → Cloud CDN → Backend services
- Open each backend service and check the Failover policy section.
- Or via
gcloud:
failoverRatio), I can adjust the Python example to match it precisely.Using Terraform
Using Terraform
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.
