Reputation: 371
I use the following Terraform configuration to try to create a subnet and a Cloud SQL MySQL 5.6 instance on Google Cloud Platform.
resource "google_compute_network" "default" {
name = "my-default-network"
auto_create_subnetworks = "true"
project = "${google_project.project.project_id}"
}
resource "google_sql_database_instance" "wordpress" {
region = "${var.region}"
database_version = "MYSQL_5_6"
project = "${google_project.project.project_id}"
settings {
tier = "db-n1-standard-1"
ip_configuration {
private_network = "${google_compute_network.default.self_link}"
}
}
}
But applying this plan gives me the following vague error. I also tried to destroy the entire project and tried to build it up again, but I get the same error.
google_sql_database_instance.wordpress: Still creating... (20s elapsed)
google_sql_database_instance.wordpress: Still creating... (30s elapsed)
google_sql_database_instance.wordpress: Still creating... (40s elapsed)
Error: Error applying plan:
1 error(s) occurred:
* google_sql_database_instance.wordpress: 1 error(s) occurred:
* google_sql_database_instance.wordpress: Error waiting for Create Instance:
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
Can anyone see what I do wrong here?
Edit:
When adding TF_LOG=debug
to the terraform apply
-run, I get the following error.
"error": {
"kind": "sql#operationErrors",
"errors": [{
"kind": "sql#operationError",
"code": "INTERNAL_ERROR"
}]
}
Edit 2: Simplified the network setup, but getting the exact same error.
Upvotes: 6
Views: 2874
Reputation: 15068
A bit late to the party but I have just had and overcome this issue. In my case it was related to using the private_networking
option. My suggestion is to read the documentation paying attention to the "Network Requirements" and check the following:
servicenetworking.googleapis.com
API enabled in your projectI found that verifying private networking was the issue (by removing it and setting ipv4_enabled = "true"
) in a temporary instance helped focus my debugging efforts.
Good Luck!
Upvotes: 1