Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration “Cloud CDN Global Backend Services Should Have Session Affinity” in GCP using GCP console, follow the below steps:
  1. Open the Google Cloud Console and select the project you want to work with.
  2. Go to the Navigation menu and select “Network Services” and then select “Cloud CDN”.
  3. In the Cloud CDN page, select the name of the backend service that you want to remediate.
  4. In the backend service page, click on the “Edit” button on the top of the page.
  5. In the “Edit backend service” page, scroll down to the “Session affinity” section.
  6. Select the “Client IP and protocol” option from the drop-down menu for “Session affinity”.
  7. Click on the “Save” button to save the changes.
By following the above steps, you have successfully remediated the misconfiguration “Cloud CDN Global Backend Services Should Have Session Affinity” in GCP using GCP console.

To remediate the misconfiguration “Cloud CDN Global Backend Services Should Have Session Affinity” for GCP using GCP CLI, you can follow these steps:
  1. Open the Cloud Shell in the GCP Console.
  2. Run the following command to list all the backend services in your project:
  1. Identify the backend service(s) that are used by your Cloud CDN.
  2. Run the following command to update the backend service(s) and enable session affinity:
Replace [BACKEND_SERVICE_NAME] with the name of the backend service you identified in step 3.
  1. Verify that session affinity is enabled for the backend service(s) by running the following command:
This command should return the following output:
This confirms that session affinity has been enabled for the backend service(s) used by your Cloud CDN.Note: Enabling session affinity may result in increased latency and decreased availability, depending on your workload. Therefore, it is important to evaluate the impact of this change before implementing it in a production environment.
To remediate the misconfiguration “Cloud CDN Global Backend Services Should Have Session Affinity” for GCP using python, you can follow the below steps:
  1. First, you need to authenticate with GCP using the below command:
  1. Next, you need to get the list of all global backend services using the below command:
  1. For each global backend service, you need to check if session affinity is enabled or not using the below command:
  1. If session affinity is not enabled for any global backend service, you can enable it using the below command:
This will enable session affinity for all the global backend services which do not have it enabled.
Substitute:
  • CDN_GLOBAL_BACKEND with your backend service name.
  • google_compute_instance_group.BACKEND_INSTANCE_GROUP and google_compute_health_check.BACKEND_HEALTHCHECK with your actual resources.
This change is an in-place update; it does not force replacement of the backend service. After updating, terraform plan should show session_affinity changing from "NONE" (or being added) to "GENERATED_COOKIE" on the affected google_compute_backend_service.