Skip to main content

Spanner Instances With Minimum Nodes Remediation

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration of Spanner Instance Nodes should be minimum in GCP, you can follow the below steps:

  1. Login to the GCP console and navigate to the Spanner Instance that needs to be remediated.

  2. Click on the Spanner Instance and navigate to the "Nodes" tab.

  3. In the "Nodes" tab, you will see the current number of nodes that are configured for the Spanner Instance.

  4. To remediate the misconfiguration, you need to reduce the number of nodes to the minimum required. The minimum number of nodes required depends on the workload and the performance requirements.

  5. To reduce the number of nodes, click on the "Edit" button on the top right corner of the "Nodes" tab.

  6. In the "Edit Node Count" dialog box, reduce the number of nodes to the minimum required and click on the "Save" button.

  7. GCP will initiate the process of reducing the number of nodes. This process may take some time depending on the number of nodes and the workload.

  8. Once the process is complete, you will see the new number of nodes in the "Nodes" tab.

  9. Verify that the Spanner Instance is working as expected with the reduced number of nodes.

By following the above steps, you can remediate the misconfiguration of Spanner Instance Nodes should be minimum in GCP using the GCP console.

Using CLI

The misconfiguration "Spanner Instances Nodes Should Be Minimum" suggests that the number of nodes in a Google Cloud Spanner instance is not set to the minimum recommended value. To remediate this issue, you can follow these steps:

  1. Open the Google Cloud Console and navigate to the Cloud Spanner instances page.

  2. Identify the instance that requires remediation and note down its instance ID.

  3. Open the Cloud Shell from the Google Cloud Console.

  4. In the Cloud Shell, run the following command to update the instance configuration:

gcloud spanner instances update INSTANCE_ID --num-nodes=1 --async

Replace INSTANCE_ID with the ID of the instance that requires remediation.

  1. Wait for the update to complete. You can check the status of the update by running the following command:
gcloud spanner operations wait OPERATION_ID

Replace OPERATION_ID with the ID of the operation that you want to check.

  1. Once the update is complete, verify that the number of nodes in the instance has been set to the minimum recommended value by running the following command:
gcloud spanner instances describe INSTANCE_ID

Replace INSTANCE_ID with the ID of the instance that you updated.

  1. Repeat the above steps for any other instances that require remediation.

By following these steps, you can remediate the "Spanner Instances Nodes Should Be Minimum" misconfiguration for Google Cloud Spanner instances using the GCP CLI.

Using Python

To remediate the misconfiguration "Spanner Instances Nodes Should Be Minimum" for GCP using Python, you can follow the below steps:

Step 1: Import the required libraries:

from google.cloud import spanner_v1
from google.oauth2 import service_account

Step 2: Set the credentials for authentication:

credentials = service_account.Credentials.from_service_account_file('<path_to_service_account_file>')

Step 3: Create a client object for Spanner:

spanner_client = spanner_v1.Client(credentials=credentials)

Step 4: Get the instance object for the Spanner instance:

instance_id = '<instance_id>'
instance = spanner_client.instance(instance_id)

Step 5: Get the current configuration for the instance:

config = instance.get()

Step 6: Set the minimum number of nodes for the instance:

config.node_count = <minimum_node_count>

Step 7: Update the instance configuration:

operation = instance.update_instance(config)
operation.result()

Note: Replace <path_to_service_account_file> with the path to your GCP service account key file, <instance_id> with the ID of your Spanner instance, and <minimum_node_count> with the desired minimum number of nodes for your instance.

By following these steps, you can remediate the misconfiguration "Spanner Instances Nodes Should Be Minimum" for GCP using Python.

Using Terraform
resource "google_spanner_instance" "THIS_INSTANCE" {
name = "SPANNER_INSTANCE_NAME" # replace with the Spanner instance ID (not display name)
config = "SPANNER_INSTANCE_CONFIG" # e.g. "regional-us-central1"
display_name = "SPANNER_INSTANCE_DISPLAY" # human‑readable name

# Ensure the node count is not above the allowed maximum.
#
# If your policy says "no more than 3 nodes", set this to 3 (or lower
# if you actually want to downsize further). Do NOT exceed that policy.
num_nodes = ALLOWED_MAX_NODE_COUNT # replace with an integer like 1, 2, 3, etc.

# Alternatively, if you use processing units instead of nodes:
# processing_units = ALLOWED_MAX_PROCESSING_UNITS # e.g. 1000 for ~1 node
}

Changing num_nodes (or processing_units) on google_spanner_instance is an in‑place update and does not replace the instance.

For verification, terraform plan should show an in-place update on google_spanner_instance.THIS_INSTANCE with num_nodes (or processing_units) changing from the current higher value down to the new allowed maximum.