The Simplest Way to Make Firestore and Google Compute Engine Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Running Firestore and Google Compute Engine together lets backend servers read and write document data fast. You attach an identity role to your virtual machine so apps talk to the database without stored keys. This setup supports web backends, worker queues, and state tracking across your cloud projects. Teams get fast document reads while keeping heavy compute tasks on dedicated virtual machines. How Firestore and Google Compute Engine share identity and data Every virtual machine in Googl

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.

Running Firestore and Google Compute Engine together lets backend servers read and write document data fast. You attach an identity role to your virtual machine so apps talk to the database without stored keys.

This setup supports web backends, worker queues, and state tracking across your cloud projects. Teams get fast document reads while keeping heavy compute tasks on dedicated virtual machines.

How Firestore and Google Compute Engine share identity and data

Every virtual machine in Google Cloud can hold a dedicated service account identity. When your app runs on that server, it requests a short token from the local metadata server. The client library uses this token to call the document database over a secure channel.

Cloud IAM rules check if that service account can read or write specific collections. You do not need to copy private key files onto the server disk. If the role matches, the database returns the requested documents to your running app.

Network traffic stays inside the Google backbone when both tools run in the same project or peering setup. You can enable private cloud access on your subnet so machines without public addresses still reach the database API.

Common failure modes with shared accounts and broad roles

Many teams leave the default compute service account active on every virtual machine they create. That default account often holds editor rights across the entire cloud project. If an attacker compromises one web server, they can read or delete every collection in your database.

Engineers also log in to production servers to debug state issues or run manual fix scripts. When five people share one machine, the cloud audit log only records the machine role. You cannot tell which person ran a destructive write or read private user documents.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static service account keys create another huge risk during local testing and server setup. Developers download JSON key files to test code and leave them on shared disks. Those keys do not expire on their own and grant full database access from any network.

Scoping roles and network paths for production

Start by creating a unique service account for each workload on your virtual machines. Grant only the exact database user role needed for that specific app to function. Disable the default compute account so no team member uses it by mistake.

Next, lock down the network path between your virtual machines and the cloud APIs. Put your servers in a private subnet with no external IP addresses attached. Use private service controls to block data movement to outside cloud projects.

Finally, separate machine traffic from human debugging work on your production data. Apps should use their attached machine identity, while engineers should log in with their own work identities. Turn on data access audit logs so your security team can review read and write events.

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 runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values 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

Do I need a JSON key file on my virtual machine to read documents?

No, you should never put JSON key files on your virtual machines. Attach a custom service account to the instance and let the client library fetch tokens from the metadata server.

Can a server without a public IP address still reach the document database?

Yes, a private virtual machine can reach the database without a public IP address. You just need to turn on private Google access on the subnet that hosts your server.

How do I stop a compromised server from wiping all my cloud resources?

Remove the default compute service account and assign a custom account with narrow database permissions. That way, the server can only touch the data collections its app needs.

The query runs. The emails stay hidden.