Error on creating backup pool in GCP

Error: Error creating TargetPool: googleapi: Error 400: Invalid value for field 'resource': '{ "name": "primary-pool", "healthCheck": ["projects/workspace/global/httpHealthChecks...'. 'backupPool' and 'failoverRatio' must be either both set or both unset., invalid

Terraform code:

resource "google_compute_forwarding_rule" "default" {
  name       = "frontend"
  target     = google_compute_target_pool.primary_pool.id
  port_range = "80"
  load_balancing_scheme = "EXTERNAL"
  ip_protocol           = "TCP"
}


resource "google_compute_target_pool" "standby_pool" {
  name = "standby-pool"

  instances = [
    "us-central1-b/standby",
  ]


  health_checks = [
    google_compute_http_health_check.default.name,
  ]

}

resource "google_compute_target_pool" "primary_pool" {
  name = "primary-pool"

  instances = [
    "us-central1-a/primary"
  ]

  backup_pool = google_compute_target_pool.standby_pool.self_link
  failover_ratio = 0

  health_checks = [
    google_compute_http_health_check.default.name,
  ]
  depends_on = [google_compute_target_pool.standby_pool]
}



resource "google_compute_http_health_check" "default" {
  name               = "default"
  request_path       = "/"
  check_interval_sec = 60
  timeout_sec        = 5
}

I’ve set both backup_pool and failover_ratio but still it throws error what could be the reason?

2 Likes

I observed that it works if failover_ratio ratio is set to a non zero value ex: 0.01 @dinolinjob did you find a solution for this (setting it to 0 ) ?

2 Likes

Console we can set it as 0 but not through terraform “google_compute_target_pool”

Yeah…it worked when failover_ratio was set to a non zero value.

Is there any specific reason for this behavior?

yes, we need to switchover to backup pool in case of complete failure.

Failover Ratio: 0 (to only switchover in case of complete failure)