Create a cloud function to export Cloud SQL databases from another project

44 views
Skip to first unread message

David Oceans

unread,
Aug 8, 2019, 12:58:39 PM8/8/19
to Google Cloud SQL discuss
Hi!

I have a cloud function created in the same project where is my cloud sql instance and is working, I'm able to export data to GCS bucket.

But I would like have all my cloud functions centralize in one project.

The question is, Can I have the cloud function in another project and be able to do export of one cloud sql instance that is in different project?
How can I do it? because I copied the code of my cloud function in another project and the execution seems work but doesn't create the bucket in the GCS

This is posible?

Thanks

John Scott Ertel

unread,
Aug 8, 2019, 1:11:02 PM8/8/19
to google-cloud...@googlegroups.com
Hi you can do this but you need to add rights to the app engine service account for your cloud function to each of the projects with a cloud sql instance you want to work with. I think the role is cloud sql user

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/42153720-6fa8-4793-a98e-4e58450a00d8%40googlegroups.com.

George (Cloud Platform Support)

unread,
Aug 8, 2019, 3:57:10 PM8/8/19
to Google Cloud SQL discuss
You can access Second Generation MySQL instances as well as PostgreSQL instances in other projects if your Cloud Function's service account (listed on the Cloud Function's General tab in the GCP Console) is added as a member in IAM on the project with the Cloud SQL instance(s) with the Cloud SQL Client role. You may read related details on the "Connecting to Cloud SQL" documentation page.

Code-wise, there is no special arrangement to access buckets in other projects, as bucket names are globally unique. You still need to grant appropriate GCS permissions to your service account.  
Reply all
Reply to author
Forward
0 new messages