Google Cloud SQL Proxy could not find default credentials

I am trying to start the Google Cloud SQL proxy locally as follows:

$ ./cloud_sql_proxy -instances project-name:region-name:instance-id tcp:3306

But he returns

google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for mor information.

My Google Cloud SDK is already installed and registered with Google.

How to fix it?

+17
source share
3 answers

Two problems can be the cause of your problem.

To find out what login is, use:

gcloud auth login

1. You do not have default credentials for the application

If you have the latest version of gcloud, you will get:

WARNING: `gcloud auth login` no longer writes application default credentials.

For your local application to use your credentials, you need to do ( ref ):

gcloud auth application-default login

, gcloud, :

gcloud components update

2.

:

Your current project is [project-id].

:

.

, (ref):

gcloud config set project PROJECT_ID

. --project

:

.\cloud_sql_proxy -instances=project-id:region-name:instance-id=tcp:3306 --project=project-id
+39

Google Apps gcloud.

gcloud auth application-default login

. . reference.

gcloud auth login , Cloud SDK .

, gcloud . gcloud auth application-default.

, , , json- console.

+9

CI/CD :

.

gcloud auth application-default login gcloud auth application-default login json , $GOOGLE_APPLICATION_CREDENTIALS

for example echo "export GOOGLE_APPLICATION_CREDENTIALS=${TF_VAR_gcp_service_account_file_loc}" >> $BASH_ENV(if you need to move env variables between steps / tasks). $BASH_ENVis a special property provided by CircleCI, if you use another CI / CD tool, you will need to find the location of the bash profile.

or just export GOOGLE_APPLICATION_CREDENTIALS=[path-to-service-account-json-file]for use in the same step

0
source

Source: https://habr.com/ru/post/1664124/


All Articles