Incorrect Service Networking config for instance: xxxx:SERVICE_NETWORKING_NOT_ENABLED
26 Apr 2025, 22:05 UTC
I'm trying to replicate a SQL instance in GCP via terraform. The active instance has a public IP, however subnets from a secondary project are shared with the project hosing the SQL instance, and the SQL instance is associated with the secondary project's network.
I've added the private_network setting properly (I think) in the ip_configuration section, however I'm getting the following error:
Error: Error, failed to create instance xxxx: googleapi: Error 400: Invalid request: Incorrect Service Networking config for instance: xxxx:xxxxx:SERVICE_NETWORKING_NOT_ENABLED., invalid
I can't find much documentation when I google that particular error, and I'm relatively new to Terraform, so I'm hoping someone can point out what I'm missing from either this section of my Terraform config, or another resource altogether.
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"
}
}
1 answer
Accepted answer · original discussion
01 May 2025, 17:17 UTC
If you see the following error:
Error: Error, failed to create instance xxxx: googleapi: Error 400: Invalid request: Incorrect Service Networking config for instance: xxxx:xxxxx:SERVICE_NETWORKING_NOT_ENABLED., invalid
Enable the Service Networking API:
gcloud services enable servicenetworking.googleapis.com --project=[PSM_PROJECT_NUMBER]
3 question comments
Use comments to ask for clarification. Post a solution as an answer.
28 Apr 2025, 02:53 UTC
ipv4_enabled = "true") and private (private_network = "projects/gcp-backend/global/networks/default"). Use one or the other but not both.29 Apr 2025, 07:41 UTC