When a BigQuery service perimeter earns its operational cost
In brief
Adopt a service perimeter for a named prohibited data-transfer path, then prove that required queries still work and the prohibited transfer fails.
- Include the job project and scheduled report refreshes when testing allowed access.
- Use dry-run violations to narrow exceptions, then retest the forbidden transfer under enforcement.
Before adding a service perimeter around BigQuery, write down one operation it must stop. For example, an account allowed to read the warehouse and write to a separate project must still be unable to copy protected data into that project.
List the allowed requests beside that prohibited transfer. Every later exception can then be tested against the same boundary.
We’d use IAM first to define who can access each data surface. Add VPC Service Controls when a real requirement also restricts where supported API operations may move or access that data.
The extra policy is worth maintaining only if the resulting restriction survives the exceptions needed to run the business.
State the boundary the service can enforce
VPC Service Controls applies a perimeter to supported Google Cloud resources and API interactions. It works alongside IAM: a perimeter exception doesn’t grant a missing data permission. It also doesn’t require a VPC network or stop arbitrary communication with third-party internet services.
Suppose an analyst has legitimate read access to a customer dataset and legitimate write access to a personal analysis project. Each grant can be reasonable on its own while the business prohibits copying this dataset to that destination. A service perimeter gives you a separate place to express that restriction for supported managed operations.
An allowed query can return rows to a browser or application. Once delivered, those rows can stay outside the perimeter as local query results or a client-side export. A perimeter can block an API transfer to an unapproved bucket. It can’t stop an authorized viewer from copying a value out of the result.
If the requirement is “the recipient must never keep any data they can see,” a perimeter can’t meet it. Narrow what that recipient receives and reconsider the delivery model.
Include the job project in the design
List the source-data project, the project containing approved views, the execution project that pays for query jobs, and the projects containing allowed export buckets.
We’d start with those approved resources inside one perimeter when their ownership allows it. The unapproved destination stays outside.
The execution project takes part in the request even when it holds no permanent data. BigQuery requires the job project to be inside the perimeter or allowed through its egress configuration. A client that picks up a different default project can fail even when its identity has the expected table permissions.
Choose protected services from the request paths. Protecting bigquery.googleapis.com also protects the BigQuery Storage, Reservation, and Connection APIs.
An export or external table involving Cloud Storage brings another service and resource into the design. Check that service’s protection and project rules too, instead of assuming the word “BigQuery” covers the whole request.
Check the analysis edition first. VPC Service Controls access is supported for Enterprise, Enterprise Plus, and on-demand analysis. It’s unavailable in Standard. If the existing workload runs on Standard reservations, budget for changing its edition before writing ingress rules.
Authorized views add another resource relationship. Include the view, source, and job projects in the request map, and keep them in the same perimeter where you can. Requests through the view involve both the source and the view project, even though the consumer has no direct IAM access to the source. For a required crossing, test the exact view authorization and request path, including what happens when that authorization changes. Don’t assume an authorized view bypasses the perimeter.
Define allowed and denied requests together
An ingress rule describes access from outside to protected resources. Egress can also be needed when a request involves an outside resource, even if its caller passed ingress.
Requests that cross several perimeters must satisfy the policies on each side. All of these rules are separate from the caller’s IAM grants.
Write a small acceptance table before proposing exceptions:
| Request | Intended outcome |
|---|---|
| Approved worker queries the source using the designated execution project | Allowed |
| Report viewer loads an approved view through the connector the report uses | Allowed |
| Required background report refresh runs without a human browser session | Allowed through its defined identity and path |
| The same authorized reader attempts the prohibited managed export to an outside destination | Denied by the perimeter |
| A caller without the required data role queries from an otherwise allowed context | Denied by IAM |
Use harmless data and controlled destinations for transfer tests. Give the negative test IAM permissions that would otherwise allow the operation. If IAM denies it first, the perimeter hasn’t been tested.
Record each request’s principal, network or access-level context, job project, destination, and API operation with its result. If an exception later names every project or allows every operation for a broad identity set, rerun the prohibited transfer. An exception that restores a report and also allows the prohibited export means the perimeter no longer meets its original requirement.
Test every context the reporting connector runs in
Opening a dashboard from an office laptop leaves its background refresh paths untested.
Data Studio can pass an interactive viewer’s IP context to BigQuery. Background deliveries don’t come from that viewer’s IP. Automated work needs extra access configuration, sometimes with service-account principals.
Test the configured credential mode and the scheduled operation itself. Keep the report’s audience restrictions intact while deciding how the request enters the perimeter. Switching to a more privileged identity because it makes the refresh succeed can change who receives data.
Don’t build an allowlist around a guessed fixed Data Studio backend IP or project. Its hosted infrastructure is dynamic. Use the supported request identity and access controls, then verify both interactive and background behavior. If the exception the connector needs allows the very transfer the perimeter was meant to stop, redesign that integration or accept that the perimeter hasn’t met this requirement.
Use dry run to discover the required exceptions
VPC Service Controls dry-run mode records proposed violations without enforcing the candidate policy. The team can observe ordinary jobs, scheduled work, and representative manual tasks before an enforcement change. Queries keep succeeding during this phase even when the candidate perimeter would block them, so judge by the violation log.
Start with the documented policy-log filter and narrow it to the test scope and interval:
log_id("cloudaudit.googleapis.com/policy")
severity="error"
protoPayload.metadata.dryRun="true"The dryRun metadata identifies candidate denials. Review both modes together. Existing enforcement runs first, and a request it already blocks may have no matching dry-run violation.
Don’t edit a shared access level as though it were a shadow copy. Access levels have no dry-run mode.
Test an access-level change with a separate candidate level. Otherwise an exercise meant only to observe can alter the context an enforced perimeter uses.
Inspect each failure’s violation reason to see whether the missing allowance concerns origin, identity, a resource project, or an operation. Approve an exception because that request belongs in the design, not because a wildcard makes an error disappear. After enforcement, rerun the allowed and prohibited cases and keep their results with the reviewed configuration.
Budget for denied-request investigation, connector changes, new projects, and exception removal. Keep the perimeter only while it blocks the prohibited transfer and the required business paths work with acceptable exceptions. If the requirement is only to limit which analysts can read a dataset, the smaller IAM change is enough.
More in this domain: Infrastructure
Browse allGive Cloud Run health probes a recovery policy
Match each Cloud Run health probe to a recovery action.
Rotating a Cloud Run credential while old revisions still exist
Keep both credentials valid while Cloud Run consumers move to a verified replacement.
Detect stalled Cloud Run work behind a healthy endpoint
Detect stalled Cloud Run work from overdue operations and their last meaningful progress.
Cloud Tasks vs. Pub/Sub for Cloud Run: routing, retries, and rate limits
Use Cloud Tasks to schedule or throttle a specific operation. Use Pub/Sub to deliver one event to independent consumers.
Cloud Run scale to zero: cold starts and minimum instances
Let Cloud Run scale to zero when the first useful request after idle time meets the caller's deadline.
Related patterns
BigQuery tenant access starts with the query identity
Choose tenant isolation from the identity BigQuery sees on the report's query.
Direct VPC egress vs. Serverless VPC Access for Cloud Run
Start with Direct VPC egress for new Cloud Run connections to a VPC.
How we decide between Cloud SQL connectors, Auth Proxy, and private IP
Choose the Cloud SQL network route and the connection helper separately. Either a language connector or the Auth Proxy can use private IP.
Safe scaling defaults for Cloud Run + Postgres
Set Cloud Run instance limits, request concurrency, and per-process pools together so the fleet fits within PostgreSQL's connection budget.