Chapter 23 · Encryption, CMEK, Network Access, Private Connectivity, and Data Governance

VPC / Private Google Access and Service Perimeter Concepts Where Applicable, Egress Paths, and Trusted Backends

Design a trusted backend network path that combines IAM, VPC Service Controls, Private Google Access, restricted endpoints, and egress policy without pretending network location is authorization.

Advanced · 160–220 minutesVPC SC · Private Google Access · egress · IAM · trusted backendNode 22+ · Firebase CLI 15.30.0 · Firestore emulator 127.0.0.1:8080Mandatory governance lab local/no-cost · CMEK/VPC/managed evidence optional cloud-onlyLast reviewed: 17 September 2026

1. AtlasMart problem: “private network” is not a database authorization model

AtlasMart moves privileged settlement and fraud services onto private-IP Cloud Run/VM infrastructure. A team member proposes: “Once Firestore traffic comes from our VPC, we can loosen IAM and Rules.” That collapses network origin, identity, and authorization into one trust decision. A compromised workload inside a trusted network would then have an oversized blast radius.

Learning outcomes
  • Separate IAM authorization, Rules, service perimeters, Private Google Access, DNS/routing, and application authorization.
  • Explain what VPC Service Controls mitigates and what it does not.
  • Design private access from VPC/on-prem workloads to supported Google APIs.
  • Distinguish Native API connectivity from MongoDB-compatible firestore.goog connectivity.
  • Model ingress/egress exceptions and test denial safely before enforcement.
Execution and safety note

Use the Emulator Suite, a Firebase demo project, or an isolated test project for destructive, security-sensitive, billing-sensitive, migration, backup/restore, or write-heavy exercises unless the lesson explicitly marks managed verification as required. Treat shown output as expected evidence unless it is explicitly identified as captured output, and re-check current Firebase/Google Cloud edition, mode, quota, pricing, and security documentation before production execution.

Chapter 23 reproducibility baseline · reviewed 17 September 2026

AtlasMart keeps project ID demo-atlasmart-firestore, Standard-edition Native mode, database (default), Node.js 22+, Firebase CLI 15.30.0, Firebase Admin Node SDK 14.4.0, Firestore emulator 127.0.0.1:8080, Auth emulator 127.0.0.1:9099, and Emulator UI 127.0.0.1:4000. Mandatory work is deterministic and local. Cloud KMS/CMEK, VPC Service Controls, Private Google Access, regional endpoints, Cloud Audit Logs, managed backup/export evidence, and real residency validation require a real Google Cloud project and are optional controlled verification steps. The emulator does not emulate KMS key availability, Google network routing, service perimeters, regional processing guarantees, or managed audit logs. This lesson uses network-policy simulation because the Firestore emulator runs locally and cannot emulate VPC Service Controls or Google API VIP routing.

Term Meaning in this chapter
Client SDK Mobile/web Firestore path normally authorized with Firebase Authentication and Security Rules; App Check can reduce abuse but does not replace authorization.
Server/Admin SDK Trusted workload path authenticated with Google credentials/IAM; it bypasses Firestore Security Rules and therefore requires application-layer authorization.
Standard / Enterprise Firestore editions with different query/index/pricing capabilities. Governance controls must be checked against the actual edition and interface.
Native Core / Pipeline Enterprise Native can expose familiar Core operations and advanced Pipeline operations. Network/encryption controls protect the database resource; query semantics still differ.
MongoDB compatibility Enterprise mode exposing a MongoDB-compatible protocol and firestore.goog endpoint. It is not MongoDB server software and has distinct private-connectivity instructions.
CMEK Customer-managed encryption key in Cloud KMS used by Firestore for server-side encryption at rest. It is not client-side encryption.
VPC Service Controls A Google Cloud data-exfiltration control that places supported managed services/resources behind a service perimeter. It complements rather than replaces IAM/Rules.

2. Four gates, four different questions

Gate Question answered Example
Network path Where can packets/API requests travel? Private Google Access + restricted VIP + firewall egress
Service perimeter May this context cross the protected data boundary? VPC Service Controls ingress/egress policy
Identity/IAM What may this workload principal do? roles/datastore.user vs narrower/custom role
Application authorization Is this user/tenant/action allowed by business policy? Order belongs to tenant; backend verifies caller role
Network controls do not replace IAM or Rules

A service perimeter mitigates exfiltration paths; it does not turn every identity inside the perimeter into an authorized database user. Likewise, a valid IAM principal does not automatically satisfy tenant/business authorization.

3. Native mode: VPC Service Controls protects the Firestore service

Firestore Native integrates with VPC Service Controls. The Firestore, Datastore, and Firestore Key Visualizer APIs are bundled for perimeter restriction. For private-IP workloads, Private Google Access lets hosts reach Google APIs without an external IP. For stronger exfiltration mitigation, restricted.googleapis.com can be used for services supported by VPC Service Controls. Routing still uses the Google API path; “private” here does not mean you created a dedicated Firestore NIC inside your VPC.

network-intent.yaml
workload: atlasmart-settlementsource: vpc/atlasmart-prod/private-subnetexternal_ip: falseprivate_google_access: trueapi_domain_policy: restricted.googleapis.comservice_perimeter: atlasmart-sensitiveidentity: settlement-saiam: least-privilege-firestoreapplication_authz: tenant + settlement-rolepublic_client_path: separate; Security Rules + App Check

4. Regional endpoints are about processing locality, not “private IP Firestore”

Native server client libraries can target regional or multi-regional Firestore endpoints to enforce data transmission, storage, and processing locality for the specified location. Mobile/web SDKs do not support this endpoint selection. Regional endpoints and Private Google Access therefore solve different requirements: one constrains service endpoint locality; the other gives private-IP workloads a private path to Google APIs. A design can require one, both, or neither.

Do not invent a compliance guarantee from the word “regional.” The policy must name the exact database location, endpoint, callers, and evidence required by your organization.

5. MongoDB compatibility has a distinct private access path

Firestore with MongoDB compatibility uses firestore.goog, not the standard firestore.googleapis.com endpoint. Google documents Private Google Access specifically for this mode. restricted.firestore.goog uses addresses only routable from within Google Cloud and is designed for VPC Service Controls scenarios. The protocol remains MongoDB-compatible over port 443.

Path Native API MongoDB compatibility
Default service name firestore.googleapis.com UID.LOCATION.firestore.goog
Restricted/private pattern restricted.googleapis.com or appropriate Google API private endpoint design restricted.firestore.goog
Protocol Firestore API/gRPC/HTTP via SDK MongoDB wire-compatible protocol over TLS/443
Authorization Rules for client paths; IAM for server paths MongoDB-compatible auth/IAM/SCRAM depending connection mode; database feature matrix applies

6. Safe perimeter rollout: dry-run before deny

Service-perimeter mistakes can create outages. A production rollout should inventory callers, destinations, cross-project access, CI/CD, backup/export buckets, observability tools, and admin workflows. Use dry-run where available, inspect violations, define explicit ingress/egress exceptions, and only then enforce.

governance/perimeter-sim.json
{  "restrictedService": "firestore.googleapis.com",  "allowedSources": ["settlement-sa@prod", "fraud-sa@prod"],  "allowedProjects": ["atlasmart-prod"],  "egressExceptions": ["approved-audit-project"],  "denyExamples": [    "developer-laptop-to-prod",    "unknown-service-account",    "export-to-unapproved-project"  ]}

The local test runner should reject every denyExamples entry. This tests your policy model; it does not prove Google Cloud perimeter evaluation.

7. Failure injection: over-trusting the VPC

Deliberately give a simulated in-VPC service an admin=true flag but a tenant mismatch. The expected result is still deny at application authorization. Then remove the application check and observe the test fail. This is the concrete proof that network trust is an input to authorization architecture, not authorization itself.

trusted-backend-authz.mjs
function authorizeSettlement({ principal, tenant, orderTenant }) {  if (!principal.vpcTrusted) throw new Error("NETWORK_CONTEXT_DENIED");  if (!principal.iam.includes("firestore.write")) throw new Error("IAM_DENIED");  if (tenant !== orderTenant) throw new Error("TENANT_DENIED");  if (!principal.roles.includes("settlement")) throw new Error("APP_AUTHZ_DENIED");  return true;}const attackerInsideVPC = {  vpcTrusted: true, iam: ["firestore.write"], roles: ["settlement"]};try { authorizeSettlement({principal: attackerInsideVPC, tenant:"tenant-a", orderTenant:"tenant-b"}); }catch (e) { console.log(e.message); } // TENANT_DENIED

Production judgment

Use VPC Service Controls when exfiltration threat and governance justify the operational complexity. Use Private Google Access/restricted paths when private-IP workloads should not depend on public internet routing. Keep browser/mobile access patterns separate because Firebase client traffic, Auth, App Check, Rules, and service-perimeter behavior have different constraints. Model every exception as a controlled data path with owner, reason, expiry/review, and audit evidence.

Knowledge check

  1. Does Private Google Access grant Firestore IAM permission?
  2. What threat does VPC Service Controls primarily mitigate?
  3. Are regional endpoints the same thing as Private Google Access?
  4. Does MongoDB compatibility use the same endpoint naming as Native?
  5. Why use dry-run before perimeter enforcement?
Review the answers

1. No; it changes the network path, not authorization.

2. Data exfiltration across managed-service boundaries.

3. No; one concerns processing locality, the other private API access.

4. No; it uses firestore.goog names and has dedicated private-access guidance.

5. To identify legitimate callers/data flows that enforcement would otherwise break.

Summary and next step

This lesson established the working contract for VPC/Private Google Access and Service Perimeter Concepts Where Applicable, Egress Paths, and Trusted Backends. Keep its edition/mode assumptions, trust boundary, verification evidence, and operational constraints explicit when reusing the pattern.

Next, continue to Database Locations, Data Residency, Multi-Region Tradeoffs, Replication, and Governance Requirements.

Authoritative references

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only Ethereum or ERC-20 compatible assets to this address.