dada
dada

Reputation: 1493

gcloud sql databases in a bash script

In the terminal (bash), when I type:

gcloud sql databases create $DATABASE_NAME --instance=${SQL_INSTANCE} --project $PROJECT

the database is successfully created.

However, when I put that same line in a bash script, I get the error:

ERROR: (gcloud) The project property must be set to a valid project ID, not the project name ["project_name"]
To set your project, run:

  $ gcloud config set project PROJECT_ID

or to unset it, run:

  $ gcloud config unset project

Even when I add gcloud config set project PROJECT_ID to the script, I still get the same error.

How I can make the gcloud sql databases create work in a bash script ?

Note : I run a OS X v10.15.7 (Catalina)

Upvotes: 0

Views: 237

Answers (1)

dada
dada

Reputation: 1493

The flag --log-http helped me see where the problem was.

The value of the variables PROJECT, SQL_INSTANCE, and DATABASE_NAME included quotes ("), such that the URL used to POST was containing %22.

Making the value of these variables without these quotes solved the problem.

Upvotes: 1

Related Questions