stackitcloud / terraform-provider-stackit

The official Terraform provider for STACKIT
https://registry.terraform.io/providers/stackitcloud/stackit
Apache License 2.0
34 stars 13 forks source link

terraform validate broken for LB network role #464

Closed burgerdev closed 1 month ago

burgerdev commented 1 month ago

The named roles for load balancer resources do not pass Terraform validation anymore.

resource "stackit_loadbalancer" "example" {
  # ...
  networks = [
    {
      network_id = openstack_networking_network_v2.example.id
      role       = "ROLE_LISTENERS_AND_TARGETS"   # <---- this 
    }
  ]
}

This used to work in v0.23.0 and is broken in v0.24.0. Looking at the relevant changes, I'd assume that #455 introduced this bug. Reproduce with:

#!/bin/sh
set -e

cat > main.tf <<EOF
terraform {
  required_providers {
    openstack = {
      source  = "terraform-provider-openstack/openstack"
      version = "1.54.1"
    }

    stackit = {
      source  = "stackitcloud/stackit"
      version = "0.24.1"
    }
  }
}

EOF

curl -sSL https://raw.githubusercontent.com/stackitcloud/terraform-provider-stackit/main/examples/resources/stackit_loadbalancer/resource.tf | 
    sed 's/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/bb101b49-ed30-4545-85ce-566335b27b2d/g' >>main.tf

terraform init
terraform validate

Output:

[...]
│ Error: Invalid Attribute Value Match
│ 
│   with stackit_loadbalancer.example,
│   on main.tf line 78, in resource "stackit_loadbalancer" "example":
│   78: resource "stackit_loadbalancer" "example" {
│ 
│ Attribute listeners[0].protocol value must be one of: ["`PROTOCOL_UNSPECIFIED`"
│ "`PROTOCOL_TCP`" "`PROTOCOL_UDP`" "`PROTOCOL_TCP_PROXY`" "`PROTOCOL_TLS_PASSTHROUGH`"], got:
│ "PROTOCOL_TCP"
╵
╷
│ Error: Invalid Attribute Value Match
│ 
│   with stackit_loadbalancer.example,
│   on main.tf line 78, in resource "stackit_loadbalancer" "example":
│   78: resource "stackit_loadbalancer" "example" {
│ 
│ Attribute networks[0].role value must be one of: ["`ROLE_UNSPECIFIED`"
│ "`ROLE_LISTENERS_AND_TARGETS`" "`ROLE_LISTENERS`" "`ROLE_TARGETS`"], got:
│ "ROLE_LISTENERS_AND_TARGETS"
╵
joaopalet commented 1 month ago

Hi @burgerdev,

Thanks a lot for reporting. It is indeed a bug introduced in our side that is addressed in #465.

joaopalet commented 1 month ago

The fix was released in v0.24.2