Skip to content

[Bug]: load_balancer_service - error when health_check retries are not set #1162

@martipoe

Description

@martipoe

What happened?

╷
│ Error: invalid input in field 'health_check' (invalid_input, 1d8a3abf498913d3363732fae0fee5dc): [health_check.healthCheckRetries => [Must be between 1 and 5.]]
│ 
│   with hcloud_load_balancer_service.load_balancer_service,
│   on hcloud_lb.tf line 30, in resource "hcloud_load_balancer_service" "load_balancer_service":
│   30: resource "hcloud_load_balancer_service" "load_balancer_service" {
│ 
╵

What did you expect to happen?

According to the docs, this setting is optional: https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs/resources/load_balancer_service

retries - (Optional, int) Number of tries a health check will be performed until a target will be listed as unhealthy.

Was able to fix the error by setting retries=5.

Please provide a minimal working example

terraform-provider-hcloud: 1.52.0
OpenTofu: 1.10.3

resource "hcloud_load_balancer_service" "load_balancer_service" {
  load_balancer_id = hcloud_load_balancer.lb01.id
  protocol         = "https"
  listen_port      = "443"
  destination_port = "80"

  http {
    certificates    = [for cert in hcloud_managed_certificate.managed_cert : cert.id]
    redirect_http   = true
    sticky_sessions = true
    cookie_name     = "HCLBSTICKY"
    cookie_lifetime = 300
  }

  health_check {
    protocol = "http"
    port     = 80
    interval = 10
    timeout  = 5

    http {
      domain       = var.base_url
      path         = "/"
      status_codes = ["200", "404"]
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions