Rasmus
08/04/2025, 11:43 AMMarvin
08/04/2025, 11:43 AMMarvin
08/04/2025, 11:44 AMcloud-run-template.json
) with the Cloud SQL configuration. Here's an example template:
json
{
"job_configuration": {
"cloud_sql_connections": [
"PROJECT:REGION:INSTANCE"
],
"vpc_connector": "projects/PROJECT_ID/locations/REGION/connectors/CONNECTOR_NAME"
}
}
Replace the following:
- `PROJECT`: Your Google Cloud project ID
- `REGION`: The region where your Cloud SQL instance is located
- `INSTANCE`: Your Cloud SQL instance name
- `PROJECT_ID`: Your Google Cloud project ID
- `CONNECTOR_NAME`: The name of your VPC connector (required for private networking)
2. Create or update your work pool with this template:
bash
prefect work-pool create "my-cloud-run-pool" \
--type cloud-run \
--base-job-template cloud-run-template.json
Important Prerequisites:
1. Ensure you have a VPC connector set up in Google Cloud (this is required for Cloud SQL access)
2. The service account used by Cloud Run must have appropriate permissions to access the Cloud SQL instance
3. Your Cloud SQL instance must be configured to accept connections from Cloud Run
Additional Notes:
- The Cloud SQL instance will be automatically mounted to your Cloud Run service
- You can connect to multiple Cloud SQL instances by adding more instances to the cloud_sql_connections
array
- Make sure your Cloud SQL instance is in the same region as your Cloud Run service for optimal performance
- The VPC connector is required for private networking between Cloud Run and Cloud SQL
For more detailed information about Google Cloud Run workers, you can refer to the Prefect GCP worker guide.
Would you like me to provide more specific details about any part of this setup, such as configuring the VPC connector or setting up the necessary IAM permissions?