1
votes

I'm trying to connect a GCE instance to a Cloud SQL instance (2nd gen) with Cloud SQL Proxy. When i ssh to the GCE instance and

sudo ./cloud_sql_proxy -dir=/cloudsql

I get

2016/07/13 18:59:28 Using gcloud's active project: xxxx-0000
2016/07/13 18:59:29 Error listing instances in xxxx-0000:
    googleapi: Error 403: Access Not Configured.
    Cloud SQL Administration API has not been used in project 000000000000
    before or it is disabled. Enable it by visiting
    https://console.developers.google.com/apis/api/sqladmin/overview?project=000000000000
    then retry.
    If you enabled this API recently, wait a few minutes for the action to
    propagate to our systems and retry., accessNotConfigured
2016/07/13 18:59:29 no Cloud SQL Instances found in these projects: [xxxx-0000]

I have followed the documentations at
https://cloud.google.com/sql/docs/compute-engine-access#gce-connect-proxy and
https://cloud.google.com/sql/docs/sql-proxy

Both instances are within the same project and Cloud SQL API is enabled on the GCE instance (plus the default ones.) By my understanding, the default GCE service account should be able to authenticate the proxy.

Using cloud_sql_proxy with -instances seems to work but errors with accessNotConfigured too while trying to connect.

2
Did you click the link in the error message? console.developers.google.com/apis/api/sqladmin/…Vadim
Yes, I did. It was disabled there, but didn't enable. I figured it was for access from external sources.sunhoww
And now that I enabled it, it's working. I should have tried that earlier. I realize now that the API needs to be enabled project-wide and the external sources would need credentials for access.sunhoww

2 Answers

2
votes

As per the error message, you need make sure that the "Cloud SQL Admin" API is enabled by visiting the provided link.

0
votes

There's also a GUI way to connect your Compute Engine instance if you're using a 2nd gen GCloud SQL instance. You first get the external IP of your compute engine and include it in the Authorizations tab of your GCloud SQL dashboard. Here's a quick video