Skip to main content

More Info:

Ensure Spanner Database Backups are encrypted with Customer Managed Keys

Risk Level

Medium

Address

Reliability, Security

Compliance Standards

  • GDPR
  • HIPAA
  • HITRUST CSF
  • ISO 27001
  • NIST CSF
  • PCI
  • SOC2
  • Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration of Spanner Database Backup not being encrypted with customer-managed keys in GCP, follow these steps:
  1. Go to the GCP Console and navigate to the Spanner instance whose backup you want to encrypt.
  2. Click on the “Backups” tab in the left-hand menu.
  3. Find the backup that needs to be encrypted and click on its name.
  4. Click on the “Encryption” tab in the top menu.
  5. Click on the “Edit” button.
  6. Select “Customer-managed key” from the “Encryption type” dropdown.
  7. Choose the appropriate key from the “Key name” dropdown.
  8. Click on the “Save” button to save the changes.
  9. Verify that the backup is now encrypted with the customer-managed key by checking the “Encryption” tab.
  10. Repeat these steps for any other Spanner backups that need to be encrypted with customer-managed keys.
By following these steps, you can remediate the misconfiguration of Spanner Database Backup not being encrypted with customer-managed keys in GCP.

To remediate this misconfiguration in GCP, you can follow these steps using GCP CLI:
  1. First, you need to create a new key ring and key using the following command:
    Replace [KEY_RING_NAME], [LOCATION], and [KEY_NAME] with your own values.
  2. Next, you need to grant the Cloud Spanner service account permission to use the key by adding the cloudkms.cryptoKeyEncrypterDecrypter role to the service account. You can use the following command:
    Replace [PROJECT_ID] and [SERVICE_ACCOUNT_EMAIL] with your own values.
  3. Now, you need to configure Cloud Spanner to use the customer-managed encryption key by updating the backup configuration. You can use the following command:
    Replace [BACKUP_ID] and [KEY_NAME] with your own values.
  4. Finally, you need to verify that the backup configuration has been updated successfully by running the following command:
    This command should return the details of the backup configuration, including the encryption configuration.
By following these steps, you can remediate the misconfiguration and ensure that your Spanner database backups are encrypted with customer-managed keys in GCP.
To remediate the misconfiguration “Spanner Database Backup Should Be Encrypted With Customer Managed Keys” for GCP using Python, you can follow these steps:
  1. Create a Customer Managed Encryption Key (CMEK) in Google Cloud KMS. This key will be used to encrypt the backups. You can use the following code to create a CMEK:
  1. Enable backup encryption for your Spanner instance. You can use the following code to enable backup encryption:
  1. Verify that backup encryption is enabled for your Spanner instance. You can use the following code to verify backup encryption:
This will ensure that your Spanner database backups are encrypted with a customer-managed encryption key in Google Cloud KMS.
Using a KMS key for an existing backup requires creating a new backup; Terraform will show this as google_spanner_backup.SPANNER_BACKUP_NAME being replaced, which deletes the old backup and creates a new CMEK‑encrypted one (backups are immutable).For verification, terraform plan should show kms_key_name being added (or changed) on the google_spanner_backup resource, and if it was previously unencrypted or using Google‑managed keys, the resource will be marked for replacement.