The Simplest Way to Make Cloud Run and Firestore Work Like They Should
Pairing cloud run and firestore gives your team a fast, serverless app stack. Your containers run stateless compute while the document store holds active state. This setup lets developers ship web APIs and background jobs with zero server upkeep. Both tools scale up on traffic spikes and scale down when idle. To make them work well together, you must align identity roles and network paths. How data and permissions flow between cloud run and firestore Each container revision runs under a dedi
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.
Pairing cloud run and firestore gives your team a fast, serverless app stack. Your containers run stateless compute while the document store holds active state.
This setup lets developers ship web APIs and background jobs with zero server upkeep. Both tools scale up on traffic spikes and scale down when idle. To make them work well together, you must align identity roles and network paths.
How data and permissions flow between cloud run and firestore
Each container revision runs under a dedicated Google Cloud service account. When your app boots, it uses the built-in metadata server to get a token. The client library attaches this token to every read and write call.
Google Cloud IAM checks this token before any database work happens. Notice that IAM roles govern server-side container calls instead of client mobile rules. If the service account holds the right role, the database executes the query. The response then travels back over Google private networks to your container.
You do not need to put static JSON keys inside your container image. The runtime refreshes tokens on its own before they expire. This flow keeps secret keys out of source control and build logs. It also lets you change database permissions without rebuilding your app container.
Common failure modes with shared accounts and broad roles
Many teams leave the default compute service account on their container services. This default account often holds broad editor rights across the whole project. If one container has a bug, it can overwrite every collection in your database. Multiple services sharing one account also make audit logs hard to read.
You cannot tell which app deleted a document when ten apps share one identity. Another common mistake occurs during live debugging and incident response. Engineers often grant their own user accounts broad data roles to fix an issue. Those personal roles stay active long after the ticket closes.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Unlogged manual queries also create blind spots for security teams. When someone queries customer collections from a laptop, standard app logs miss the event. Customer emails, phone numbers, and card numbers can sit on local disks. You need clear boundaries for both runtime containers and human operators.
Scoping roles and network paths for production workloads
Start by creating a unique service account for every single container service. Grant each account only the narrowest database role it needs to work. Read-only worker services should never hold write or delete rights. Split sensitive data into separate projects or databases if you need hard boundaries.
Keep all traffic between your compute service and the database on internal network paths. Use VPC Service Controls to stop data from leaving your cloud boundary. This stops someone from using a stolen token outside your network.
Turn on data audit logs for your sensitive collections to track every read and write. When engineers need to inspect live records, avoid handing out permanent project roles. Require peer reviews for write actions and mask sensitive fields like national IDs in results.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Should I use Firebase security rules or IAM for my container service?
Use IAM roles for your container service. Server client libraries use service account tokens, which bypass mobile security rules by default.
How do I stop cold starts when my container connects to the database?
Initialize your database client once in global scope when the container starts. Reusing this client across requests avoids slow setup steps on every call.
Can two Cloud Run services share the same Firestore database safely?
Yes, two services can share one database if each uses its own service account. Track their actions in audit logs and keep their roles tight.
Related guides
In this post