Is it possible to connect to Google Cloud SQL from a Google Managed VM?

牧云@^-^@ 提交于 2019-12-03 16:33:57

The /cloudsql/ sockets are only available in regular App Engine. Managed VMs are regular VMs so connection to Cloud SQL needs to use the external IP of that Cloud SQL instances. The external IP needs to be whitelisted. The external IP is showed in the Developers Console and can also be retrieved via gcloud CLI tool.

Two options to avoid having to whitelist the IP of the GCE VMs are:

  1. Switch to use only SSL connections for IP connectivity and whitelist 0.0.0.0/0.
  2. Funnel all the traffic to Cloud SQL via a VM that runs a TCP proxy (HAProxy) for example.

We are aware that none of these are very satisfying solutions. :-(

If you're willing to try out Cloud SQL Second Generation (currently in Beta), there's built-in support for connecting from Managed VMs that is similar to App Engine: https://cloud.google.com/sql/docs/sql-proxy#gae

Everything is described here depends on language: https://cloud.google.com/sql/docs/dev-access more details with pythons are here:

subject: Step 2: Grant your App Engine application access to the Google Cloud SQL instance https://cloud.google.com/appengine/docs/python/cloud-sql/

Concerning the first solution provided by @Razvan Musaloiu-E

Switch to use only SSL connections for IP connectivity and whitelist 0.0.0.0/0.

Are there any security concerns if I do this ? Besides from having a "root"/"root" login/pasword on my Cloud SQL database of course...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!