Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Communicate a Cloud Run from one GCP project to a Cloud SQL in another GCP project

I have a Cloud Run running in one VPC project, and I need it to be able to connect to a Cloud SQL database in another GCP project, but I don't know how to achieve this.

0 2 632
2 REPLIES 2

julien_bisconti
Google Developer Expert
Google Developer Expert

Hi Norteña,

Cloud Run is in project A and Cloud SQL is in project B.

Create a service account in project A.

Add the service account from project A to the Cloud SQL instance's IAM policy in project B.

Setup the connection by following https://cloud.google.com/sql/docs/mysql/connect-run#private-ip

I hope it helps,

 

Julien

Hi,

If by chance the suggestion of Mr. @julien_bisconti did not work, my other advice would be to configure the VPC peering[1]. This allows private communication between the resources in different projects.

Then I also agree with the IAM Permission suggest by Mr. @julien_bisconti through service account.

[1]https://cloud.google.com/vpc/docs/using-vpc-peering

Top Solution Authors