我正在尝试通过terraform在GCP中复制SQL实例。活动实例具有公共IP,但来自次要项目的子网与托管SQL实例的项目共享,并且SQL实例与次要项目的网络相关联。
我已经正确添加了ip_configuration
部分中的private_network
设置(我想),但是我收到了以下错误:
错误:错误,无法创建实例xxxx:googleapi:错误400:无效请求:不正确的服务网络配置实例:xxxx:xxxxx:SERVICE_NETWORKING_NOT_ENABLED.,无效
当我谷歌这个特定的错误时,我找不到太多文档,并且我对Terraform相对较新,因此我希望有人可以指出我从我的Terraform配置的这个部分或另一个资源中漏掉了什么。
resource "google_sql_database_instance" "cloudsql-instance-qa" {
depends_on = [google_project_service.project_apis]
database_version = "MYSQL_5_7"
name = "${var.env_shorthand}-${var.resource_name}"
project = var.project_id
region = var.region
settings {
activation_policy = "ALWAYS"
availability_type = "ZONAL"
backup_configuration {
binary_log_enabled = "true"
enabled = "true"
point_in_time_recovery_enabled = "false"
start_time = "15:00"
}
crash_safe_replication = "false"
disk_autoresize = "true"
disk_size = "5003"
disk_type = "PD_SSD"
ip_configuration {
ipv4_enabled = "true"
private_network = "projects/gcp-backend/global/networks/default"
require_ssl = "false"
}
location_preference {
zone = var.zone
}
maintenance_window {
day = "7"
hour = "4"
}
pricing_plan = "PER_USE"
replication_type = "SYNCHRONOUS"
tier = "db-n1-standard-1"
}
}
ipv4_enabled =“true”
)和私有IP地址(private_network =“projects/gcp-backend/global/networks/default”
)。请使用其中之一,而不是两者同时使用。 - John Hanleyipv4_enalbed
设置为false
,但仍然遇到相同的错误。我需要在其他地方更新设置吗?当前活动/工作的实例既具有公共IP又具有私有IP,并且与次要项目中的网络相关联。 - NealR