How to Configure Gemini CLI Bigquery Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up gemini cli bigquery read only access by assigning a viewer role to the agent identity. You also grant a job runner role so the agent can run read queries without modifying tables. Many engineering teams start by running the terminal agent under their own personal developer profiles. This shortcut gives the coding assistant the same broad cloud permissions that the human engineer holds. If the user has write permissions, the agent can drop tables or alter production schemas by mistake.

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 gemini cli bigquery read only access by assigning a viewer role to the agent identity. You also grant a job runner role so the agent can run read queries without modifying tables. Many engineering teams start by running the terminal agent under their own personal developer profiles. This shortcut gives the coding assistant the same broad cloud permissions that the human engineer holds. If the user has write permissions, the agent can drop tables or alter production schemas by mistake.

How to set up gemini cli bigquery read only access

To lock down the agent, you first create a dedicated service identity in your cloud project. You do not let the terminal tool use your personal login credentials. Next, you attach two basic permission sets to this new identity. First, the identity needs a data viewer role on the target datasets. This role lets the agent read table metadata and rows. Second, the identity needs permission to create and run query jobs inside the project. In BigQuery, even a read query runs as an asynchronous job that needs compute quota.

Once the cloud roles are ready, you point the local terminal session to those new credentials. The Gemini CLI tool runs shell commands and helper tools using the active shell profile. When the agent needs to check a schema or sample rows, it uses the scoped identity. If the agent tries to run a write statement, the cloud API blocks the job right away. You can scope the data viewer role to a single dataset rather than the whole project. This stops the agent from reading tables outside its assigned work area.

What native roles solve and what they leave open

Native cloud roles do a great job of blocking table changes and deletions. They enforce a strict boundary at login and job creation time. Still, cloud roles only check who starts the job and which dataset they touch. They do not inspect the actual query text or filter the rows that come back.

A read-only role still lets an AI agent scan an entire customer table in one query. When the query finishes, the raw rows flow straight into the terminal and out to the model prompt. Those rows often hold sensitive strings like emails, phone numbers, card numbers, or national IDs. Also, native roles cannot require a human peer to approve a heavy query before it runs. Finally, project logs show that the shared service identity ran a query, not which developer prompted it.

Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why query-level controls matter for AI agents

AI coding tools work fast and generate many database queries during a single debugging session. Static cloud roles treat every read query from the agent the same way. Teams need a way to inspect each query in flight and apply dynamic data masking. Masking rewrites matched fields like emails or card numbers in the query results before the agent reads them. Tying each terminal prompt to an individual user identity also gives security teams clear audit logs.

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 does a read-only BigQuery identity still need job permissions?

BigQuery processes every select statement by creating a query job. Without permission to create jobs in the project, the identity can list tables but cannot query them.

Can cloud IAM roles hide sensitive columns from Gemini CLI?

Standard dataset viewer roles grant read access to every column in the allowed tables by default. To restrict specific columns or rewrite sensitive values like phone numbers, you need finer policy controls.

What happens if Gemini CLI uses my default local cloud login?

The agent inherits every permission attached to your personal cloud account. If your account can edit or delete datasets, the agent can run those commands too.

The query runs. The emails stay hidden.