0
votes

I am running a cloud build trigger on a cloudbuid.yaml file in which I build a docker container and then deploy it to cloud run. The error stacktrace is as follows:

API [sql-component.googleapis.com] not enabled on project 

The problem is that I have enabled both SQL and SQL Admin APIs in both projects (one for the cloud build and one for the database), which was confirmed in the console and in gcloud.

Here is the yaml code for the step I am referring to:

- name: 'gcr.io/cloud-builders/gcloud'
  args: [
    'beta',
    'run',
    'deploy',
    'MY_NAME',
    '--image', 'gcr.io/MY_PROJECT/MY_IMAGE',
    '--region', 'MY_REGION',
    '--platform', 'managed',
    '--set-cloudsql-instances', 'MY_CONNECTION_NAME',
    '--set-env-vars', 'NODE_ENV=production,INSTANCE_CONNECTION_NAME=MY_CONNECTION_NAME,SQL_USER=MY_USER,SQL_PASSWORD=MY_PASSWORD,SQL_NAME=MY_SCHEMA,TOPIC_NAME=MY_TOPIC'
  ]

Any suggestions?

Thanks.

P.S.: As per Eespinola suggestion, I checked and confirmed I am running Google Cloud SDK 254.0.0.

P.S. 2: I have also tried to create a project from scratch but ended up with the same results.

1
I was investigating about this and I found that this could be related with your Cloud SDK version. I have found this tracked issue, where it says that would be fixed in Cloud SDK 254.0.0. Let me know if it works for you! - ericcco
Hi there eespinola. Thank you for your interest. I have also found that issue and confirmed I am running Cloud SDK 254.0.0. - Pedromlm

1 Answers

1
votes

Ok so as per the same thread eespinola posted (see above), the Cloud Build gcloud step will be updated according to Cloud SDK 254.0.0 update in a near future (the actual date may or may not be posted in the same thread in the future). Until then, the alternative is to use the YAML file without the --add-cloudsql-instances flag and add it manually in the UI (I still have not tried this but it should work as per Google's development team).