Ensure that your Google Cloud Platform (GCP) Cloud Spanner databases are encrypted using customer-managed encryption keys (CMEK) instead of the default Google-managed encryption keys. CMEK provides organizations with greater control over their encryption keys, enabling them to create, rotate, and manage encryption keys through Cloud Key Management Service (Cloud KMS). This ensures compliance with regulatory requirements and enhances data security by giving organizations full ownership and control over their encryption strategy. CMEK supports Cloud KMS software keys, Cloud Hardware Security Module (HSM) keys, and Cloud External Key Manager (Cloud EKM) keys. The encryption keys must be in the same location as the Cloud Spanner instance, and for multi-region or dual-region configurations, multiple regional Cloud KMS keys can be used to protect the database. Once a database is created with a specific encryption configuration, the encryption type cannot be changed unless you back up and restore the database or export and import the data to a new database with CMEK enabled.
By using customer-managed encryption keys (CMEK) for Cloud Spanner databases, organizations gain complete control over their encryption keys and data protection strategy. CMEK enables you to manage key protection levels, locations, rotation schedules, usage permissions, and access controls through Cloud KMS, ensuring that encryption practices align with organizational security policies and compliance requirements. With CMEK, you can define who can access your data by controlling the permissions on your encryption keys, implement custom key rotation policies, and maintain a comprehensive audit trail of all key usage through Cloud Audit Logs. Additionally, CMEK provides the ability to render data inaccessible by disabling or destroying the encryption key, giving organizations an additional layer of control in data breach scenarios, regulatory investigations, or during secure decommissioning processes. CMEK does not impact Cloud Spanner's performance or service level agreement (SLA), making it a seamless security enhancement. Without CMEK, organizations rely entirely on Google's default encryption practices, which may not meet specific compliance frameworks or internal security standards that require customer-controlled encryption key management for sensitive data workloads.
Important: If a Cloud KMS key is deleted, any Cloud Spanner databases encrypted with that key become permanently inaccessible and the data cannot be recovered. If a Cloud KMS key is disabled, Cloud Spanner will immediately make the database inaccessible. If the key remains disabled for more than seven days, Cloud Spanner automatically deletes the database. Key changes can take up to three hours to propagate throughout the system. It is strongly recommended against disabling or destroying only a subset of keys in a multi-region CMEK database, as this can lead to inconsistent database states.
Audit
To determine if your Cloud Spanner databases are encrypted with customer-managed encryption keys (CMEK), perform the following operations:
Remediation / Resolution
To enable customer-managed encryption keys (CMEK) for your Google Cloud Spanner databases, you must create a new Cloud Spanner database with CMEK configured, migrate your data from the existing database to the new database, and then delete the old database. Before creating the new database, you must create a Cloud KMS encryption key (or multiple regional keys for multi-region instances) in the same location as your Spanner instance and grant the Cloud Spanner service agent the necessary permissions to use the key. Perform the following operations:
Important: Cloud Spanner does not support modifying the encryption type of an existing database from Google-managed keys to customer-managed encryption keys (CMEK). You must create a new database with CMEK enabled and migrate your data using backup and restore operations or database export and import. Ensure that you have appropriate backup and migration strategies in place before proceeding. The Cloud KMS encryption key must be created in the same location as your Cloud Spanner instance. For multi-region or dual-region instances, you must use multiple regional Cloud KMS keys (one for each region) rather than a multi-region Cloud KMS key. Deleting or disabling the CMEK key will make your Cloud Spanner database inaccessible, and if the key remains disabled for more than seven days, Cloud Spanner will automatically delete the database.References
- Google Cloud Platform (GCP) Documentation
- Secure a database with customer-managed encryption keys (CMEK)
- Customer-managed encryption keys (CMEK) overview
- Always-on database with virtually unlimited scale
- Backups overview
- Create a key
- Cloud Key Management Service overview
- Customer-managed encryption keys (CMEK)
- Permissions and roles
- GCP Command Line Interface (CLI) Documentation
- gcloud spanner instances list
- gcloud spanner instances describe
- gcloud spanner databases list
- gcloud spanner databases describe
- gcloud spanner databases create
- gcloud kms keyrings create
- gcloud kms keys create
- gcloud kms keys add-iam-policy-binding
- gcloud beta services identity create
- gcloud projects list