How to Configure Spanner Encryption at REST
Google Cloud turns on spanner encryption at rest by default for every database. You can also set up customer-managed keys in Cloud Key Management Service for more control. Many teams stop after they set up disk keys and basic cloud roles. Still, broad database roles still let logged-in users read plain data in every table. How spanner encryption at rest works in Google Cloud Google Cloud encrypts all data before it writes the bytes to disk. The system splits your database into smaller chunks
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Google Cloud turns on spanner encryption at rest by default for every database. You can also set up customer-managed keys in Cloud Key Management Service for more control. Many teams stop after they set up disk keys and basic cloud roles. Still, broad database roles still let logged-in users read plain data in every table.
How spanner encryption at rest works in Google Cloud
Google Cloud encrypts all data before it writes the bytes to disk. The system splits your database into smaller chunks and gives each chunk its own key. A master key then wraps those chunk keys to keep them safe. When you use default settings, Google rotates and manages these master keys for you.
Some teams need to own the master key to meet strict audit rules. In this case, you create a key ring and key inside Cloud KMS. You must place the key in the same region or multi-region as your instance. Next, you grant the database service account permission to use that specific key.
You link the KMS key when you create a new database or backup. After setup, the database calls your KMS key to manage the local chunk keys. If you revoke or disable the KMS key, the database stops serving reads and writes. This setup gives your security team a hard switch to lock down stored data.
What disk keys solve and what they leave open
Disk encryption protects your data if someone steals a physical drive from a data center. Customer-managed keys also help you pass audits that demand key rotation and revoke controls. If a whole project is compromised, you can disable the key to freeze the database.
Still, encryption at rest does not protect data from active database sessions. Once a user or app logs in with valid permissions, the database decrypts the data. Any developer with a read role can run a query and pull full tables. Storage keys only check if the database service can read the disk.
Storage encryption cannot tell who is running a query or what rows they fetch. It cannot rewrite sensitive fields like emails, phone numbers, card numbers, or national IDs. Also, Cloud KMS logs only show key checks by the database service itself. They do not record which engineer ran an ad-hoc query during a live session.
Encryption at Rest + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Managing key lifecycles and database roles
To keep your setup safe, you should separate key admin roles from database roles. The person who manages KMS keys should not have read access to database tables. Likewise, database admins should not have the power to delete or disable KMS keys. This split stops one compromised account from unlocking and dumping your stored data.
You also need a plan for backups when you rotate or destroy keys. Backups use the KMS key version that was active when the backup ran. If you destroy an old key version, you can no longer restore that backup. Always check which backups depend on a key version before you remove it.
Finally, pair your storage setup with tight controls over live database sessions. Limit who can run direct queries against production tables during daily work. Masking rewrites matched fields in results so support staff only see safe values. Combining disk encryption with query-level rules protects your data both on disk and in flight.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev sits inline in the protocol beside each supported service as an open-source proxy, a sidecar for your database or API. For every query or command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human approval.
First, hoop.dev guardrails block banned queries before they run or hold risky ones for review, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Can I add a customer-managed key to an existing database?
You must choose your KMS key when you create the database. To switch an existing database to a new key, export and restore the data.
What happens to my database if I disable my Cloud KMS key?
The database loses access to its master key within a few minutes. All active reads, writes, and backups will fail until you re-enable the key.
Does spanner encryption at rest protect data from broad IAM roles?
No, the database decrypts data by default for any user with valid read permissions. You need query controls and data masking to limit what logged-in users receive.
Related guides
In this post