All posts

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

You just deployed a Cloud Run service, hit the database, and then watched it fail with a “connection refused.” Classic. The app container runs fast, but the database might as well be on another planet. The heart of the issue is access, not queries. Connecting Cloud Run to Cloud SQL without fumbling keys or breaking security policy is trickier than it looks. Cloud Run runs stateless containers on demand. Cloud SQL hosts persistent databases with all the comforts of managed storage. Each shines a

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, hit the database, and then watched it fail with a “connection refused.” Classic. The app container runs fast, but the database might as well be on another planet. The heart of the issue is access, not queries. Connecting Cloud Run to Cloud SQL without fumbling keys or breaking security policy is trickier than it looks.

Cloud Run runs stateless containers on demand. Cloud SQL hosts persistent databases with all the comforts of managed storage. Each shines alone, but together they form a sweet spot for modern infrastructure. The first scales to zero, the second never sleeps. The problem is teaching them to trust each other without handing out password souvenirs.

The integration starts with identity. Using a Cloud SQL Connector, your service authenticates with its service account identity instead of static credentials. That small shift replaces manual secrets with managed tokens validated by IAM. You let Google negotiate TLS and ephemeral connections under the hood. Developers stop juggling JSON keys and focus on schema design instead.

When troubleshooting, the usual trap surfaces: mismatched region or network configuration. Keep the Cloud Run service and Cloud SQL instance close. Latency is real, even inside Google’s network. Another pro tip—set minimum instances on Cloud Run if your app needs “warm” connections. Otherwise, your first query after idle time pays the cold-start tax.

Best practices that make this setup boring in the best way:

  • Use IAM roles like Cloud SQL Client instead of custom permissions.
  • Rotate service accounts only via IAM, never by redeploying secrets.
  • Monitor connection count and timeouts through Cloud Logging.
  • Keep private IP enabled for consistent throughput.
  • Add retry logic for connection resets during automatic scaling.

The payoff is simplicity. You get:

Continue reading? Get the full guide.

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

Free. No spam. Unsubscribe anytime.
  • Lower operational noise from fewer manual secrets.
  • Stronger security through workload identity.
  • Faster deployments since networking and auth just work.
  • Predictable performance thanks to managed connection pooling.
  • Clearer audit trails through IAM events instead of config files.

For developers, this changes daily life. No more SSH tunnels or waiting for a DBA to “approve access.” A new engineer can deploy, connect, and log activity using the same identity chain tied to their role. That’s developer velocity in practice, not a slide deck metric.

AI tooling only amplifies this need. When automated agents query production data for analysis, they must inherit the same contextual identity. Otherwise, you risk shadow credentials and audit gaps. Identity-aware patterns keep machine access as accountable as human access.

Platforms like hoop.dev turn those access rules into guardrails that enforce policy automatically. Instead of hardcoding credentials, requests flow through an environment-agnostic identity-aware proxy that ensures every connection is both authorized and logged.

How do I connect Cloud Run and Cloud SQL?
Grant your Cloud Run service account the Cloud SQL Client role, attach the Cloud SQL Connector, and point your app to the instance connection name. The platform negotiates secure, short-lived connections without exposing passwords or private keys.

Why choose Cloud Run Cloud SQL integration over self-managed options?
Because it cuts secret sprawl, scales elastically, and aligns with zero-trust design. You get managed reliability and compliance without the manual plumbing.

Tying Cloud Run and Cloud SQL together is not about code. It is about trust built into the runtime fabric. Once that’s in place, databases finally feel local again.

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