How to Configure Spanner Proxy
To set up a spanner proxy workflow, you pair Google Cloud IAM roles with standard database adapters. Your team routes client requests through a local protocol adapter that translates SQL into Cloud Spanner API calls. Many teams start by giving developers broad IAM project roles so their local tools work right away. When roles are too broad, any user with a valid key can run destructive queries across production tables. How a native spanner proxy architecture works Cloud Spanner does not accep
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.
To set up a spanner proxy workflow, you pair Google Cloud IAM roles with standard database adapters. Your team routes client requests through a local protocol adapter that translates SQL into Cloud Spanner API calls. Many teams start by giving developers broad IAM project roles so their local tools work right away. When roles are too broad, any user with a valid key can run destructive queries across production tables.
How a native spanner proxy architecture works
Cloud Spanner does not accept raw TCP database sockets on a public port by default. Instead, client apps talk to the Google Cloud API using cloud credentials and gRPC transport channels. When engineers use standard SQL tools, they run a Google-supplied protocol adapter on their host or cluster. This adapter listens on a local port and speaks the PostgreSQL wire protocol to standard database clients. The adapter takes incoming SQL queries and converts them into Cloud Spanner API calls in real time.
To log in, the adapter checks the host for Google Cloud service account keys or user tokens. Next, Cloud IAM checks if that identity holds a role that permits reading or writing database rows. You can assign roles at the project level, the instance level, or the individual database level. Fine-grained access control also lets admins grant permissions on specific tables or views inside the database. Once IAM approves the role, the session starts and the user can send SQL statements.
What native IAM roles solve and what they miss
Cloud IAM does a great job of verifying who can reach your Cloud Spanner instances. It blocks unknown users and ties every database login to a known Google Cloud identity. You can also turn on Cloud Audit Logs to record which identity ran a query and when. For service-to-service traffic, this native setup keeps your data perimeter tight and well defined.
Still, IAM checks happen at the resource level rather than inspecting the risk of each live query. If an engineer needs write permissions to fix one broken row, IAM grants write access to the whole table. That engineer can now run an unfiltered update or drop a table by mistake during the session. Also, anyone with read permissions on customer tables receives raw emails, phone numbers, and card numbers in results. Storing static service account keys on developer laptops also creates a risk if a device gets lost.
Why teams separate login rules from query controls
Managing temporary database permissions through Cloud IAM bindings takes too much manual work for platform teams. Every time a developer needs to check a production bug, someone must grant and later revoke an IAM role. When teams forget to remove these roles, temporary permissions turn into permanent standing access over time.
Database Proxy (ProxySQL, PgBouncer) + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
To fix this, engineering teams move away from static keys and broad IAM role assignments for human users. They keep strict IAM rules for apps while adding statement-level controls for engineers who run ad-hoc queries. Masking rules can also rewrite sensitive fields like national IDs in query results before they reach the screen. This approach keeps daily fixing fast while protecting production tables from bad queries and data leaks.
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
Does Cloud Spanner need a protocol adapter for all apps?
No, apps using native Cloud Spanner client libraries connect directly to the Google Cloud API. You only need the PostgreSQL adapter when using standard SQL tools or third-party drivers.
How does Cloud Spanner handle database passwords?
Cloud Spanner does not use traditional database passwords for user logins. It relies entirely on Google Cloud IAM principals, user tokens, and service account keys to verify identities.
Can native IAM roles hide sensitive columns in query results?
Fine-grained roles can block a user from reading restricted columns or tables altogether. Still, native IAM cannot rewrite or mask specific patterns like emails or card numbers inside returned rows.
Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.
Teams test new role rules in staging first. Clear owner lists speed up each audit. Small role scopes cut down on risk. Regular log checks catch drift right away.
Related guides
In this post