Deploying Prefect Workflows on Cloud Run with Cloud SQL (Production-Ready GCP Setup)
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
- Create a Cloud SQL instance (Private IP)
- Build a Docker image for the Prefect flow
- Push the image to Artifact Registry
- Deploy the image to Cloud Run
- Configure IAM roles properly
- 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: