我想在项目中创建一个 Cloud SQL 实例,连接到主机 VPC。但是,在运行时,terraform apply
我每次都会得到相同的结果:
google_sql_database_instance.default: Still creating... [1m20s elapsed]
google_sql_database_instance.default: Still creating... [1m30s elapsed]
google_sql_database_instance.default: Still creating... [1m40s elapsed]
google_sql_database_instance.default: Still creating... [1m50s elapsed]
Error: Error waiting for Create Instance:
Error: Process completed with exit code 1.
我在这里看到了其他答案,声称通过配置私有服务访问来解决问题,但这似乎并不能解决我的问题。
这是我的 terraform 文件,其中包含相关部分:
google_compute_global_address" "private_ip_address" {
provider = google-beta
project = data.google_compute_subnetwork.subnet.project
name = "private-ip-address"
purpose = "VPC_PEERING"
address_type = "INTERNAL"
prefix_length = 16
network = data.google_compute_network.shared-vpc.id
}
resource "google_service_networking_connection" "private_vpc_connection" {
provider = google-beta
network = data.google_compute_network.shared-vpc.id
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = [google_compute_global_address.private_ip_address.name]
}
resource "google_sql_database_instance" "default" {
provider = google-beta
project = module.base_shared_vpc_project.project_id
name = var.db_name
database_version = "MYSQL_5_7"
region = "us-east1"
settings {
tier = "db-f1-micro"
availability_type = "ZONAL"
location_preference {
zone = "us-east1-b"
}
ip_configuration {
ipv4_enabled = false
private_network = data.google_compute_network.shared-vpc.id
}
}
depends_on = [google_service_networking_connection.private_vpc_connection]
}
最后一点信息,设置TF_LOG=DEBUG
仅提供以下附加消息:Retry Transport: Stopping retries, last request failed with non-retryable error