All posts

The simplest way to make Cloud Run Firestore work like it should

You just deployed a Cloud Run service and it needs to fetch data from Firestore. It sounds simple until your deploy fails because of an IAM permission issue that only happens under production service accounts. Welcome to the classic Cloud Run Firestore dance, where identity and access meet latency and confusion. Cloud Run handles stateless containers beautifully. Firestore, meanwhile, provides a strongly consistent, serverless NoSQL database. Each shines on its own. Together, they create the ba

Free White Paper

End-to-End Encryption + Sarbanes-Oxley (SOX) IT Controls: The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

You just deployed a Cloud Run service and it needs to fetch data from Firestore. It sounds simple until your deploy fails because of an IAM permission issue that only happens under production service accounts. Welcome to the classic Cloud Run Firestore dance, where identity and access meet latency and confusion.

Cloud Run handles stateless containers beautifully. Firestore, meanwhile, provides a strongly consistent, serverless NoSQL database. Each shines on its own. Together, they create the backbone of many real-time apps—provided you can wire them up securely and efficiently. The key is identity: letting Cloud Run act as a predictable service principal when calling Firestore, every time, no matter which region or revision your container runs on.

The typical workflow starts with your Cloud Run service identity. Assign it the minimum Firestore permissions, usually datastore.user or a custom role that matches your query profile. This keeps reads and writes scoped. Then check that your code uses Google’s application default credentials, which Cloud Run injects automatically. When Firestore sees the signed token, it recognizes the Cloud Run identity through IAM, approves the request, and returns data with no client secrets or embedded keys.

If your container uses multiple services—say, talking to Firestore, Storage, and Pub/Sub—group permissions by use case, not container. One service per role, one policy per environment. This makes audits and rotations faster than chasing scattered secrets. For debugging tricky 403 errors, log GOOGLE_APPLICATION_CREDENTIALS status and enable verbose Firestore client logs. Ninety percent of the time it’s an IAM mismatch or an environment variable missing from your deploy.

Quick answer: To connect Cloud Run to Firestore, run workloads under a service identity with proper IAM roles, rely on Application Default Credentials, and avoid storing keys inside containers. Permissions flow through Google Cloud IAM automatically.

Continue reading? Get the full guide.

End-to-End Encryption + Sarbanes-Oxley (SOX) IT Controls: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

Benefits of Cloud Run Firestore integration

  • Consistent, keyless authentication with least privilege by default
  • Zero secret storage inside containers or build pipelines
  • Instant scalability under load without reworking database connections
  • Clear IAM audit trails that map real requests to service roles
  • Faster iteration since developers never touch credentials manually

Once this pattern is running, development speed jumps. You can spin up review environments without worrying about rewriting credentials or updating .env files. Every instance has the same trusted identity, so testing, QA, and production all operate under a clean, auditable model.

Platforms like hoop.dev turn those access rules into guardrails that enforce policy automatically. Instead of writing custom proxy code for each service, teams can route container requests through controlled identities and stay consistent across Cloud Run, Firestore, and beyond.

AI tooling also loves this setup. When automated agents or copilots query production data, identity-aware services keep access scoped, preventing hallucinated scripts from leaking sensitive fields. The result is safe automation that still moves fast.

Secure access, predictable identity, and zero secrets. That’s what makes Cloud Run Firestore finally feel effortless.

See an Environment Agnostic Identity-Aware Proxy in action with hoop.dev. Deploy it, connect your identity provider, and watch it protect your endpoints everywhere—live in minutes.

Get started

See hoop.dev in action

One gateway for every database, container, and AI agent. Deploy in minutes.

Get a demoMore posts