How to Configure Spanner Access Denied

Published
Length
3 min read

Luis Felipe Dias

All posts

You fix a spanner access denied error by granting the right cloud role. You must also check fine-grained database roles on specific tables and views. Most engineering teams start by giving users or apps broad project roles. This approach fixes the error fast, but it creates a big security risk. Broad roles let any user read or change sensitive tables across the instance. How native roles cause a spanner access denied error Google Cloud Spanner checks permissions at two distinct levels before

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 fix a spanner access denied error by granting the right cloud role. You must also check fine-grained database roles on specific tables and views. Most engineering teams start by giving users or apps broad project roles. This approach fixes the error fast, but it creates a big security risk. Broad roles let any user read or change sensitive tables across the instance.

How native roles cause a spanner access denied error

Google Cloud Spanner checks permissions at two distinct levels before running a query. First, Cloud IAM checks if the user or service account can reach the database. If the identity lacks a database reader or user role, the request fails. The system returns an error before the session even starts.

Second, the database engine checks fine-grained access control inside the schema itself. A user might have permission to open a session on the instance. Still, that user still needs explicit grants on the target table or column. If the database role lacks select or update rights, the query stops.

Network rules and service perimeters also trigger these permission errors in production. A service account with full admin rights will still fail if blocked by network rules. You must check project logs to see which layer rejected the request. The log entry shows whether cloud IAM or database grants blocked the action.

Why teams grant broad roles to fix permission errors

Finding the exact missing grant takes time during a live production outage. Engineers often assign a full database admin role just to get an app running. Temporary fixes often stay in place forever because nobody wants to break the app. Soon, dozens of developers and services hold full write rights in production.

Fine-grained roles inside the database take work to maintain over time. Every new table or view needs an update to the role grants. Teams must also sync these internal database roles with their cloud identity groups. Many teams skip this step and fall back to database-wide permissions.

Customer Support Access to Production: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native database roles leave open in production

Native cloud and database roles only decide who can log in and query tables. Once a user has a valid role, every query runs without extra checks. A developer with read rights can pull millions of rows at any time. Native roles cannot rewrite sensitive fields like emails, phone numbers, or card numbers.

Standard permissions also cannot require a peer review before a destructive update runs. If an engineer holds write rights to fix a bug, they can drop rows. Static roles stay active all day, even when no ticket or incident exists. Teams need a way to control individual queries and mask data in flight.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Why do I get a permission error when I have the database user role?

The database might use fine-grained access control for specific tables and views. Your cloud identity also needs a mapped database role with explicit table grants.

How can I tell if Cloud IAM or the database blocked my query?

Check the error details in your cloud audit logs for the failed request. Cloud IAM errors mention missing cloud permissions, while database errors mention table privileges.

How do I limit raw data exposure without breaking read queries?

Use dynamic data masking to rewrite matched fields like national IDs in query results. This lets engineers run diagnostic queries while keeping sensitive values hidden in the output.

The query runs. The emails stay hidden.