In traditional network security, you build a firewall around a data center. If the data is inside the perimeter, it is safe. In the public cloud, this concept is obliterated. Google Cloud Platform (GCP) services like Cloud Storage (GCS) and BigQuery do not inherently sit inside your private Virtual Private Cloud (VPC). They sit on Google’s public edge network, accessible via global public APIs (e.g., storage.googleapis.com).
Even if you configure Identity and Access Management (IAM) perfectly, a massive data exfiltration risk remains. If a malicious insider (or a compromised service account) with read access to your corporate BigQuery dataset also owns a personal, free-tier GCP project, they can simply write a script to execute a SELECT * FROM your_db and pipe the results directly into their personal BigQuery dataset. Because the IAM user has permission to read the data, Google Cloud happily executes the transfer.
To stop this, you must deploy VPC Service Controls (VPC SC). VPC SC allows you to draw an invisible, cryptographic perimeter around your GCP projects, strictly prohibiting data from flowing across the boundary, regardless of IAM permissions.
This guide explains the architecture of VPC SC and how to implement a secure service perimeter.
Understanding the VPC SC Architecture
VPC SC operates at the organizational level. It establishes a Service Perimeter.
When you place Project A and Project B inside a perimeter, and restrict the storage.googleapis.com API:
- A VM in Project A can freely write data to a Cloud Storage bucket in Project B.
- If a VM in Project A attempts to write data to a Cloud Storage bucket in Project C (which is outside the perimeter), VPC SC intercepts the API call and blocks it, returning a
VPC_SERVICE_CONTROLS_DENIEDerror. - Crucially, if a user on the public internet (even an Administrator with full IAM credentials) tries to read the bucket in Project A, VPC SC blocks them, because they are calling the API from an IP address outside the perimeter.
Step 1: Preparing for VPC SC (The Dry Run)
Warning: Deploying VPC SC incorrectly will instantly break your production environment. If you block an API that your application relies on, the application will crash. You must always use Dry Run mode first.
- Navigate to the Google Cloud Console.
- Switch your context to the Organization level (VPC SC cannot be managed at the project level).
- Go to Security > VPC Service Controls.
- Click New Perimeter.
- Perimeter Name: Prod-Data-Boundary.
- Perimeter Type: Regular.
Step 2: Defining the Perimeter Geometry
You must define what is inside the perimeter, and what services the perimeter protects.
- Under Projects to protect, add the specific production projects containing your sensitive BigQuery and GCS data.
- Under Restricted Services, select the APIs you want to lock down. For a standard data perimeter, select Google Cloud Storage API and BigQuery API.
- Critical Step: At the bottom of the configuration, toggle the mode from Enforced to Dry Run.
- Click Create Perimeter.
In Dry Run mode, VPC SC will not block any traffic. Instead, it logs every API call that would have been blocked to Cloud Logging. You must let this run for several days to capture all batch jobs, cron scripts, and user workflows.
Step 3: Analyzing Dry Run Violations
You must query Cloud Logging to identify what traffic crossed the boundary.
logName="projects/YOUR_PROJECT/logs/cloudaudit.googleapis.com%2Fpolicy_violation"
You will see logs detailing the caller IP, the principal (user or service account), and the requested resource. For example, you might discover that your CI/CD pipeline (hosted in GitHub Actions) is attempting to push artifacts to a Cloud Storage bucket inside the perimeter. Because GitHub’s IP addresses are outside the perimeter, VPC SC flagged the violation.
Step 4: Creating Ingress and Egress Rules
To fix the violations found in the Dry Run, you create Ingress Rules (allowing external identities to pull data in) or Egress Rules (allowing internal identities to push data out).
To allow your CI/CD pipeline access, you can create an Ingress Rule:
- Edit the Perimeter and navigate to Ingress Policy.
- Click Add Rule.
- From: Specify the exact Service Account used by GitHub Actions (e.g.,
[email protected]). - To: Select Projects inside the perimeter, select the Cloud Storage API, and specify the exact method (e.g.,
google.storage.objects.create).
This punches a microscopic, cryptographically secure hole in the perimeter exclusively for that specific service account to perform that specific action.
Step 5: Enforcing the Perimeter
Once you have analyzed the Dry Run logs, created the necessary Ingress/Egress rules, and verified that no legitimate traffic is still triggering violation logs, you are ready to enforce.
- Edit the Perimeter.
- Toggle the mode from Dry Run to Enforced.
- Save the Perimeter.
Propagation takes a few minutes. Once active, your cloud environment is fundamentally transformed. It is no longer a collection of public endpoints, but a fortified, isolated enclave mathematically immune to unauthorized data exfiltration.
Conclusion
Identity and Access Management controls who can access data; VPC Service Controls dictates from where and to where that data can flow. By implementing a rigid VPC SC perimeter, enterprise security architects can neutralize the catastrophic risk of malicious insiders and compromised credentials, enforcing absolute data sovereignty within Google Cloud.