How to Configure Spanner Read Only User

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a spanner read only user by assigning cloud reader roles. You can also combine cloud roles with fine-grained database role grants. Teams often share broad project roles during fast setup phases. Those wide permissions let users change rows or drop tables by mistake. A strict read role stops unwanted writes before they hit your data. How a spanner read only user works in architecture Google Cloud Spanner checks access at two separate layers. The first layer is the cloud identity and

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.

You set up a spanner read only user by assigning cloud reader roles. You can also combine cloud roles with fine-grained database role grants. Teams often share broad project roles during fast setup phases. Those wide permissions let users change rows or drop tables by mistake. A strict read role stops unwanted writes before they hit your data.

How a spanner read only user works in architecture

Google Cloud Spanner checks access at two separate layers. The first layer is the cloud identity and access control system. An admin grants a predefined reader role at the project level. Admins can also scope this role to one instance or database. This cloud role lets a principal read every table in that database. It blocks any create, update, or delete statements from running.

The second layer uses fine-grained access control inside the database engine. This option works when a team needs table-level or column-level limits. First, the admin gives the user a cloud role for fine-grained access. Next, the admin creates a database role inside the database engine. The admin grants select permissions on specific tables to that database role. Finally, the admin links the cloud identity to the new database role. When the user logs in, they only query the allowed tables.

Why teams separate cloud roles and database roles

Cloud roles work well for broad service accounts and reporting apps. A reporting app often needs to read all tables in one database. Giving it a single cloud reader role keeps setup simple and fast. The team does not need to update grants when new tables appear.

Human users and support staff often need tighter rules. A support engineer may only need to check order status tables. Fine-grained database roles restrict that engineer from reading billing tables. Still, maintaining two role layers across many databases takes extra work. Admins must track both cloud policies and internal database grants during audits.

Read-Only Root Filesystem + User Provisioning (SCIM): architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native read roles solve and what they leave open

Native read roles stop accidental writes and schema changes very well. An engineer with a read role cannot drop a table or edit rows. This setup protects data integrity during debugging and daily reporting tasks.

Still, native roles only check who logs in and which tables they read. They do not inspect what individual queries do in flight. A user with table read access can run a massive full-table scan. More importantly, select access on a table returns every allowed column raw. If a customer table holds emails, phone numbers, or card numbers, results show them. Fine-grained column grants can block whole columns, but break queries expecting those fields. Masking rewrites matched fields like national IDs in results without breaking the query shape. Native roles also require separate audit log setup to track every single query.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits inline in the protocol beside the service as an open-source proxy, a sidecar for your database or API. On every production query an agent or human runs, hoop.dev decides whether to pass, mask, block, or escalate it for review.

Before a query runs, hoop.dev guardrails check the statement against your rules, an AI Analyzer you configure can score intent or hold risky calls for human approval, and hoop.dev data masking rewrites sensitive fields in responses in memory. Explore the MIT-licensed project on GitHub.

Frequently asked questions

What is the difference between cloud reader roles and fine-grained roles?

A cloud reader role grants read access to an entire database at once. Fine-grained roles let you limit read permissions to specific tables and views.

Can a spanner read only user change database schemas?

No, a read role blocks all data updates and schema change statements. The user can only run select queries and inspect allowed metadata.

Do read-only roles hide sensitive fields in query results?

Native read roles do not rewrite data inside allowed columns. If a user can read a column, they receive the raw emails or card numbers stored there.

The query runs. The emails stay hidden.