4

I am trying to create a CloudSQL instance using terraform but its not even trying to create it appears: The CloudSQL dashboard doesnt change

enter image description here

google_sql_database_instance.db-instance: Still creating... [9m41s elapsed]
google_sql_database_instance.db-instance: Still creating... [9m51s elapsed]
google_sql_database_instance.db-instance: Still creating... [10m1s elapsed]

It eventually timesout. Why is that?

resource "google_sql_database_instance" "db-instance" {
  # depends_on = [google_service_networking_connection.private-vpc-connection]

  name = "sonarqube"
  database_version = "POSTGRES_9_6"
  region = "asia-southeast1"
  settings {
    tier = "db-f1-micro"
    # ip_configuration {
    #   private_network = google_compute_network.private-network.self_link
    # }
  }
}

I even removed the private networking parts

1 Answer 1

12

Ok, so I set TF_LOG=DEBUG and saw

2019-11-23T22:04:41.365+0800 [DEBUG] plugin.terraform-provider-google-beta_v3.0.0-beta.1_x4: 2019/11/23 22:04:41 [DEBUG] Dismissed an error as retryable. Waiting for other concurrent Cloud SQL operations to finish - googleapi: Error 409: The instance or operation is not in an appropriate state to handle the request., invalidState

After some googling, I found https://github.com/hashicorp/terraform/issues/20972

This happens because instance names cannot be reused for up to a week after it's deleted.

So I guess the issue is because I am attempting to create an instance with a name that was recently used ...

Sign up to request clarification or add additional context in comments.

1 Comment

Indeed in order to be able to reuse a name already used in a new CloudSQL instance, you have to wait for 7 days. In case it's really important for you to reuse the name and you have a support package on Google Cloud Platform support, you can open a ticket about it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.