All posts

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

Your Cloud Run service boots cleanly, scales perfectly, and then smacks right into a permissions wall when trying to talk to Cloud Spanner. The logs say “Permission denied,” and your morning coffee gets cold while you hunt through IAM roles. The fix isn’t hard, but it does require understanding how Cloud Run and Spanner expect to see each other. Cloud Run runs stateless containers that respond to HTTP requests. Cloud Spanner is Google’s fully managed relational database built for high consisten

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.

Your Cloud Run service boots cleanly, scales perfectly, and then smacks right into a permissions wall when trying to talk to Cloud Spanner. The logs say “Permission denied,” and your morning coffee gets cold while you hunt through IAM roles. The fix isn’t hard, but it does require understanding how Cloud Run and Spanner expect to see each other.

Cloud Run runs stateless containers that respond to HTTP requests. Cloud Spanner is Google’s fully managed relational database built for high consistency and massive scale. They speak the same API language, but they live in different trust zones. If your Cloud Run service wants to write or query Spanner, it needs an identity that Spanner trusts. This link is what many teams overlook when setting up production access.

The integration flow looks like this: You assign a service account to your Cloud Run deployment. That account carries credentials that Spanner checks through IAM before it allows queries. Cloud Run handles token rotation automatically, so you never store secrets inside the container. The Spanner client library picks up those tokens from metadata right inside the runtime environment. Once permissions align, your app can execute SQL as if it’s sitting inside Google’s backbone.

To keep it secure, follow some boring but vital steps. Give the Cloud Run service account only the minimum role needed, often spanner.databaseUser. Do not reuse general-purpose service accounts; make one per service. If you have multiple environments, map each to distinct accounts with environment-scoped permissions. Use audit logs in Cloud Spanner to confirm queries originate from expected identities. For external users or automation, tie identity providers like Okta through Cloud IAM with OIDC policies.

Quick answer: To connect Cloud Run to Cloud Spanner, deploy with a specific service account that has Spanner database access. The tokens refresh automatically, avoiding manual key rotation or hardcoded secrets.

Continue reading? Get the full guide.

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

Free. No spam. Unsubscribe anytime.

Building this pattern brings clear benefits:

  • No credentials in code or containers
  • Granular identity control through IAM
  • Consistent audit trails for every query
  • Automatic scaling from Cloud Run without new config
  • Fewer human touches, fewer forgotten keys

For developers, this translates directly to speed. You push code, Cloud Run deploys, and access works instantly. There’s no waiting on a security team to issue keys or approve database access. Debugging becomes faster since logs tie back to single identities. Every run feels lighter, and onboarding a new teammate takes minutes instead of hours.

Platforms like hoop.dev turn those access rules into guardrails that enforce policy automatically. They watch identities move through your stack and ensure every request follows the right authentication path. The same principles that secure Cloud Run Spanner also apply to any service boundary—making the system self-defending rather than just well-configured.

As AI copilots start approving deployments or writing integration scripts, identity-aware access like this matters more than ever. It keeps automated agents from overstepping into production data or bypassing compliance flows. When everything is identity-driven, intelligence becomes safe by design.

Cloud Run and Spanner were built to scale, but they shine only when trust flows smoothly between them. Once you nail that relationship, you get speed, clarity, and the confidence to build without second-guessing your access model.

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