Skip to main content

More Info:

Ensure Cloud CDN backend buckets have CDN enabled.

Risk Level

High

Address

Operational Maturity, Performance Efficiency, Reliability, Security

Compliance Standards

CBP

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration “Cloud CDN Backend Buckets CDN Should Be Enabled” in GCP, you can follow the below steps using GCP Console:
  1. Open the GCP Console and navigate to the Cloud Storage page.
  2. Click on the name of the bucket that you want to enable for Cloud CDN.
  3. Click on the “Edit bucket details” button at the top of the page.
  4. Scroll down to the “Cloud CDN” section and click on the “Enable Cloud CDN” checkbox.
  5. Click on the “Save” button at the bottom of the page to save the changes.
Once you have enabled Cloud CDN for the backend bucket, you can verify the configuration by checking the Cloud CDN page in the GCP Console. The backend bucket should now be listed as a resource in the Cloud CDN page.

To remediate the misconfiguration “Cloud CDN Backend Buckets CDN Should Be Enabled” for GCP using GCP CLI, follow these steps:
  1. Open the Cloud Shell in the GCP console.
  2. Run the following command to enable the Cloud CDN API:
  3. Run the following command to create a Cloud Storage bucket:
    Replace <location> with the location where you want to create the bucket (e.g. us-central1) and <bucket-name> with the name of your bucket.
  4. Run the following command to enable the Cloud CDN for the bucket:
    This command sets up the bucket as a static website and enables the Cloud CDN for it.
  5. Verify that the Cloud CDN is enabled for the bucket by running the following command:
    Replace <backend-bucket-name> with the name of your backend bucket. Look for the cdnPolicy field in the output. It should show "cacheMode": "CACHE_ALL_STATIC" which confirms that the Cloud CDN is enabled for the bucket.
  6. Repeat steps 3-5 for each backend bucket that needs the Cloud CDN enabled.
By following these steps, you have successfully remediated the misconfiguration “Cloud CDN Backend Buckets CDN Should Be Enabled” for GCP using GCP CLI.
To remediate the misconfiguration “Cloud CDN Backend Buckets CDN Should Be Enabled” in GCP using Python, you can follow these steps:
  1. Import the necessary libraries:
  1. Set up the GCP credentials:
  1. Initialize the Compute Engine client:
  1. Get the current configuration of the backend bucket:
  1. Update the configuration to enable CDN:
  1. Verify that CDN is enabled:
This should output “CACHE_ALL_STATIC”, indicating that CDN is enabled for the backend bucket.Note: You will need to replace [PROJECT_ID], [BACKEND_BUCKET_NAME], and “my-key-name” with the appropriate values for your GCP project and backend bucket.

Additional Reading: