Skip to content

Error applying stackit_application_load_balancer with metrics but without logs #1418

@codello

Description

@codello

Description

When trying to create a stackit_application_load_balancer with metrics but without logs, the provider exits with an error.

Steps to reproduce

resource "stackit_public_ip" "ip" {
  project_id = var.project_id
}

resource "stackit_loadbalancer_observability_credential" "metrics" {
  project_id   = var.project_id
  display_name = "metrics"
  username     = var.metrics_username
  password     = var.metrics_password
}

resource "stackit_application_load_balancer" "alb" {
  project_id       = var.project_id
  name             = "alb"
  plan_id          = "p10"
  external_address = stackit_public_ip.ip.ip

  disable_target_security_group_assignment = true

  listeners = [{
    protocol = "PROTOCOL_HTTP"
    name     = "http"
    port     = 80
    http = {
      hosts = [{
        host = "*"
        path = {
          prefix = "/"
        }
        rules = [{
          target_pool = "default"
          web_socket  = true
        }]
      }]
    }
    waf_config_name = var.alb_waf_config
  }, {
    protocol = "PROTOCOL_HTTPS"
    name     = "https"
    port     = 443
    http = {
      hosts = [{
        host = "*"
        path = {
          prefix = "/"
        }
        rules = [{
          target_pool = "default"
          web_socket  = true
        }]
      }]
    }
    https = {
      certificate_config = {
        certificate_ids = [var.alb_certificate_id]
      }
    }
    waf_config_name = var.alb_waf_config
  }]
  networks = [
    {
      network_id = var.network.id
      role       = "ROLE_LISTENERS_AND_TARGETS"
    }
  ]
  options = {
    ephemeral_address    = false
    private_network_only = false
    observability = {
      # no logs = ... specified. Same behavior for explicit logs = null.
      metrics = {
        credentials_ref = stackit_loadbalancer_observability_credential.metrics.credentials_ref
        push_url        = var.alb_metrics.push_url
      }
    }
  }
  target_pools = [
    {
      name        = "default"
      target_port = 80
      targets     = [{ ip = var.alb_target }]
      tls_config = {
        enabled = false
      }
    }
  ]
}
  1. Run tofu init
  2. Run tofu apply

Actual behavior

The plan succeeds but on apply, Tofu exits with the following error (file references slightly inaccurate):

│ Error: Error updating Application Load Balancer
│
│   with module.ske.stackit_application_load_balancer.alb,
│   on ../modules/ske/main.tf line 45, in resource "stackit_application_load_balancer" "alb":
│   45: resource "stackit_application_load_balancer" "alb" {
│
│ Payload for update: converting options: converting observability logs: (Value Conversion Error) An unexpected error was encountered trying to build a value. This is always an error in
│ the provider. Please report the following to the provider developer:
│
│ Received null value, however the target type cannot handle null values. Use the corresponding `types` package type, a pointer type or a custom type that handles null values.
│
│ Path:
│ Target Type: alb.observabilityOption
│ Suggested `types` Type: basetypes.ObjectValue
│ Suggested Pointer Type: *alb.observabilityOption

Expected behavior

I expect the apply step to succeed.

Current workaround: Including a dummy credential for logs makes the apply step succeed.

resource "stackit_loadbalancer_observability_credential" "logs" {
  project_id   = var.project_id
  display_name = "logs-dummy"
  username     = "dummy"
  password     = "dummy"
}

resource "stackit_application_load_balancer" "alb" {
# ...
options = {
  observability = {
    logs = {
      credentials_ref = stackit_loadbalancer_observability_credential.logs.credentials_ref
      push_url = "http://dummy"
    }
    metrics = {
      credentials_ref = stackit_loadbalancer_observability_credential.metrics.credentials_ref
      push_url        = var.alb_metrics.push_url
    }
  }
}

Environment

  • OS: macOS 26.4.1
  • Terraform version (see terraform --version): OpenTofu v1.11.6
  • Version of the STACKIT Terraform provider: v0.92.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions