Google Cloud SQL Connection Error - 403: Access Not Configured - despite having enabled the API
Asked Answered
S

1

7

I'm attempting to connect to a Google Cloud SQL instance via a MySQL client which requires me to connect via the Google Cloud proxy. I have followed all instructions on the Google Cloud Docs, yet after running the command to start the proxy (using correct INSTANCE_CONNECTION_NAME and PATH_TO_KEY_FILE), I receive the following error.

Command :

./cloud_sql_proxy -dir=/cloudsql -instances=INSTANCE_CONNECTION_NAME \ -         credential_file=PATH_TO_KEY_FILE &

Error :

couldn't connect to "INSTANCE_CONNECTION_NAME": ensure that the account has access to "INSTANCE_CONNECTION_NAME" (and make sure there's no typo in that name). Error during createEphemeral for INSTANCE_CONNECTION_NAME: googleapi: Error 403: Access Not Configured. Cloud SQL Administration API has not been used in project 563584335869 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/sqladmin.googleapis.com/overview?project=563584335869 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., accessNotConfigured

I have confirmed that the Google Cloud SQL API is enabled on the console for the project, but the weird thing is my project name is not 563584335869, and I have already set the correct project name via the GC CLI to no avail. So when visiting https://console.developers.google.com/apis/api/sqladmin.googleapis.com/overview?project=563584335869, I see:

The API "sqladmin.googleapis.com" doesn't exist or you don't have permission to access it

I also created a service account under the role Cloud SQL Client, and downloaded the private key which PATH_TO_KEY_FILE points to.

Scalp answered 8/7, 2018 at 18:58 Comment(2)
Your INSTANCE_CONNECTION_NAME should follow this pattern: project_id:region:instance_id (you can copy it from Cloud SQL section of the Cloud Console). Check that if 563584335869 is not your project_idSinus
I'm getting this same weird error. Have you managed to find a solution?Thomasson
P
0

Can you confirm that you have enabled the "Cloud SQL API" (sqladmin.googleapis.com) and not "Cloud SQL" API? (sql-component.googleapis.com)?

Can you also give some more information as to your environment? Are you running this from your local machine or are you working in Cloud Shell?

Proleg answered 9/7, 2018 at 20:18 Comment(2)
Thanks for your help. I can confirm that I have enabled the "Cloud SQL API", and i'm running this from my local MacOS machine.Scalp
Did you add the correct permissions to your service account? It should have the "Cloud SQL Client" role added under the IAM page.Proleg

© 2022 - 2024 — McMap. All rights reserved.