Deploying Prefect Workflows on Cloud Run with Cloud SQL (Production-Ready GCP Setup)

Published: (February 21, 2026 at 01:58 AM EST)
2 min read
Source: Dev.to

Source: Dev.to

Architecture Overview

Flow: Prefect Agent → Cloud Run Container → Cloud SQL (Private IP)

Why this approach works well

  • Fully serverless compute ⚡
  • Auto‑scaling
  • No VM maintenance
  • Secure database connectivity
  • Clean separation of orchestration and execution

Key Implementation Steps

  1. Create a Cloud SQL instance (Private IP)
  2. Build a Docker image for the Prefect flow
  3. Push the image to Artifact Registry
  4. Deploy the image to Cloud Run
  5. Configure IAM roles properly
  6. Connect Cloud Run to Cloud SQL

Common Mistakes

  • Forgetting to use the Cloud SQL Auth Proxy
  • Not configuring a VPC connector
  • Using a public IP for the database

Ideal Use Cases

  • ETL pipelines
  • Background microservices
  • Event‑driven automation
  • Internal workflow platforms

Architecture Check

Question: In a Cloud Run (2nd gen) setup connecting to Cloud SQL via Private IP without a Serverless VPC Connector, what enables network access?

Answer: B) Direct VPC egress configuration

Interview Tip

If an interviewer asks, “Why would you choose Cloud Run over GKE for workflows?” you can respond with a concise rationale and reference a full step‑by‑step guide:

Full guide with commands

0 views
Back to Blog

Related posts

Read more »