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.
Try Terraform on Google Cloud tutorials, courses, and self-paced training from Google Cloud Skills Boost . In this lab, you install Terraform and create a VM instance using Terraform. In this lab, you write infrastructure as code with Terraform.
In the Google Cloud console, go to the Cloud SQL Instances page. To open the Overview page of an instance, click the instance name. Select Connections from the SQL navigation menu. In the Authorized networks section, click Add network and enter the IP address of the machine where the client is installed.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With