0
votes

I’m running into issues with using terraform (version 11.14) and GCP’s SQL api.

2019/06/27 18:18:44 [DEBUG] plugin: waiting for all plugin processes to complete…
Error: Error refreshing state: 1 error occurred:
* google_sql_database_instance.loadtest-db: 1 error occurred:
2019-06-27T18:18:44.876-0400 [DEBUG] plugin.terraform-provider-google_v1.20.0_x4: 2019/06/27 18:18:44 [ERR] plugin: plugin server: accept unix /var/folders/5v/9clr5rgs3dg3y7363q9204rc0000gp/T/plugin261867312: use of closed network connection
2019-06-27T18:18:44.876-0400 [DEBUG] plugin.terraform-provider-google-beta_v1.20.0_x4: 2019/06/27 18:18:44 [ERR] plugin: plugin server: accept unix /var/folders/5v/9clr5rgs3dg3y7363q9204rc0000gp/T/plugin356238661: use of closed network connection
* google_sql_database_instance.loadtest-db: google_sql_database_instance.loadtest-db: Error reading SQL Database Instance “lt20190627”: googleapi: Error 403: Cloud SQL Admin 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

The problem is that isn’t any of my project ids, the link therefore doesn't work. I am able to directly use gcloud against SQL, and terraform has no issues setting up the rest of the environment.

1

1 Answers

1
votes

Do you recognize that project id from any of the other projects you have. Is it perhaps the project id where the account used to authenticate the job in Terraform belongs to?

There is a known issue that I believe lies in Terraform (I was not able to reproduce it using the GCP APIs), that needs API(s) (eg.: Cloud SQL Admin in this case) to be enabled in the project where the authenticated account was created instead of the project where the resources are being created. This behavior is rather confusing, though it's the only path currently to get the API to work.