stackitcloud / terraform-provider-stackit

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

Load balancer type confusion in the provider logic #265

Closed 3u13r closed 8 months ago

3u13r commented 8 months ago

Hello,

when trying to create a load balancer with the provider (Version 0.11.0) I get the following error during apply:

An error occurred: terraform apply: terraform apply: exit status 1

Error: Value Conversion Error

  with module.stackit_loadbalancer[0].stackit_loadbalancer.example,
  on modules/stackit_loadbalancer/main.tf line 10, in resource "stackit_loadbalancer" "example":
  10: resource "stackit_loadbalancer" "example" {

An unexpected error was encountered while verifying an attribute value
matched its expected type to prevent unexpected behavior or panics. This is
always an error in the provider. Please report the following to the provider
developer:

Expected framework type from provider logic:
types.ObjectType["use_source_ip_address":basetypes.BoolType] / underlying
type: tftypes.Object["use_source_ip_address":tftypes.Bool]
Received framework type from provider logic: types.ObjectType[] / underlying
type: tftypes.Object[]
Path: target_pools[0].session_persistence

The load balancer is defined as follows:

resource "stackit_loadbalancer" "example" {
  project_id = "XXX"
  name       = "${var.name}-lb"
  target_pools = [
    for portName, port in var.ports : {
      name        = "target-pool-${portName}"
      target_port = port
      targets = [
        for ip in var.member_ips : {
          display_name = "target-${portName}"
          ip           = ip
        }
      ]
      active_health_check = {
        healthy_threshold   = 10
        interval            = "3s"
        interval_jitter     = "3s"
        timeout             = "3s"
        unhealthy_threshold = 10
      }
    }
  ]
  listeners = [
    for portName, port in var.ports : {
      name        = "listener-${portName}"
      port        = port
      protocol    = "PROTOCOL_TCP"
      target_pool = "target-pool-${portName}"
    }
  ]
  networks = [
    {
      network_id = var.network_id
      role       = "ROLE_LISTENERS_AND_TARGETS"
    }
  ]
  external_address = var.external_address
  options = {
    private_network_only = false
  }
}

Note that when quering the StackIT API under https://load-balancer.api.eu01.stackit.cloud/v1/projects/XXX/load-balancers the load balancer is created with the following status:

    "loadBalancers": [
        {
            "name": "b5f0c2c0-lb",
            "version": "lb-232826804",
            "externalAddress": "193.148.173.247",
            "privateAddress": "",
            "options": {
                "privateNetworkOnly": false,
                "ephemeralAddress": false
            },
            "networks": [
                {
                    "networkId": "XXX",
                    "role": "ROLE_LISTENERS_AND_TARGETS"
                }
            ],
            "listeners": [
                {
                    "displayName": "tcp-9000",
                    "name": "tcp-9000",
                    "port": 9000,
                    "protocol": "PROTOCOL_TCP",
                    "targetPool": "target-pool-bootstrapper",
                    "serverNameIndicators": [],
                    "tcp": null,
                    "udp": null
                },
                {
                    "displayName": "tcp-4000",
                    "name": "tcp-4000",
                    "port": 4000,
                    "protocol": "PROTOCOL_TCP",
                    "targetPool": "target-pool-debugd",
                    "serverNameIndicators": [],
                    "tcp": null,
                    "udp": null
                },
                {
                    "displayName": "tcp-8132",
                    "name": "tcp-8132",
                    "port": 8132,
                    "protocol": "PROTOCOL_TCP",
                    "targetPool": "target-pool-konnectivity",
                    "serverNameIndicators": [],
                    "tcp": null,
                    "udp": null
                },
                {
                    "displayName": "tcp-6443",
                    "name": "tcp-6443",
                    "port": 6443,
                    "protocol": "PROTOCOL_TCP",
                    "targetPool": "target-pool-kubernetes",
                    "serverNameIndicators": [],
                    "tcp": null,
                    "udp": null
                },
                {
                    "displayName": "tcp-9999",
                    "name": "tcp-9999",
                    "port": 9999,
                    "protocol": "PROTOCOL_TCP",
                    "targetPool": "target-pool-recovery",
                    "serverNameIndicators": [],
                    "tcp": null,
                    "udp": null
                },
                {
                    "displayName": "tcp-30081",
                    "name": "tcp-30081",
                    "port": 30081,
                    "protocol": "PROTOCOL_TCP",
                    "targetPool": "target-pool-verify",
                    "serverNameIndicators": [],
                    "tcp": null,
                    "udp": null
                }
            ],
            "targetPools": [
                {
                    "name": "target-pool-bootstrapper",
                    "targetPort": 9000,
                    "targets": [
                        {
                            "displayName": "target-bootstrapper",
                            "ip": "192.168.178.137"
                        },
                        {
                            "displayName": "target-bootstrapper",
                            "ip": "192.168.178.96"
                        }
                    ],
                    "activeHealthCheck": {
                        "timeout": "3s",
                        "interval": "3s",
                        "intervalJitter": "3s",
                        "healthyThreshold": 10,
                        "unhealthyThreshold": 10
                    }
                },
                {
                    "name": "target-pool-debugd",
                    "targetPort": 4000,
                    "targets": [
                        {
                            "displayName": "target-debugd",
                            "ip": "192.168.178.137"
                        },
                        {
                            "displayName": "target-debugd",
                            "ip": "192.168.178.96"
                        }
                    ],
                    "activeHealthCheck": {
                        "timeout": "3s",
                        "interval": "3s",
                        "intervalJitter": "3s",
                        "healthyThreshold": 10,
                        "unhealthyThreshold": 10
                    }
                },
                {
                    "name": "target-pool-konnectivity",
                    "targetPort": 8132,
                    "targets": [
                        {
                            "displayName": "target-konnectivity",
                            "ip": "192.168.178.137"
                        },
                        {
                            "displayName": "target-konnectivity",
                            "ip": "192.168.178.96"
                        }
                    ],
                    "activeHealthCheck": {
                        "timeout": "3s",
                        "interval": "3s",
                        "intervalJitter": "3s",
                        "healthyThreshold": 10,
                        "unhealthyThreshold": 10
                    }
                },
                {
                    "name": "target-pool-kubernetes",
                    "targetPort": 6443,
                    "targets": [
                        {
                            "displayName": "target-kubernetes",
                            "ip": "192.168.178.137"
                        },
                        {
                            "displayName": "target-kubernetes",
                            "ip": "192.168.178.96"
                        }
                    ],
                    "activeHealthCheck": {
                        "timeout": "3s",
                        "interval": "3s",
                        "intervalJitter": "3s",
                        "healthyThreshold": 10,
                        "unhealthyThreshold": 10
                    }
                },
                {
                    "name": "target-pool-recovery",
                    "targetPort": 9999,
                    "targets": [
                        {
                            "displayName": "target-recovery",
                            "ip": "192.168.178.137"
                        },
                        {
                            "displayName": "target-recovery",
                            "ip": "192.168.178.96"
                        }
                    ],
                    "activeHealthCheck": {
                        "timeout": "3s",
                        "interval": "3s",
                        "intervalJitter": "3s",
                        "healthyThreshold": 10,
                        "unhealthyThreshold": 10
                    }
                },
                {
                    "name": "target-pool-verify",
                    "targetPort": 30081,
                    "targets": [
                        {
                            "displayName": "target-verify",
                            "ip": "192.168.178.137"
                        },
                        {
                            "displayName": "target-verify",
                            "ip": "192.168.178.96"
                        }
                    ],
                    "activeHealthCheck": {
                        "timeout": "3s",
                        "interval": "3s",
                        "intervalJitter": "3s",
                        "healthyThreshold": 10,
                        "unhealthyThreshold": 10
                    }
                }
            ],
            "status": "STATUS_ERROR",
            "errors": [
                {
                    "type": "TYPE_TARGET_NOT_ACTIVE",
                    "description": "No active target server(s) with IP(s): 192.168.178.137 192.168.178.96"
                },
                {
                    "type": "TYPE_FIP_NOT_CONFIGURED",
                    "description": "Floating IP \"193.148.173.247\" could not be found."
                }
            ]
        },
joaopalet commented 8 months ago

Hello,

Thank you for opening the issue, we are looking into it.

joaopalet commented 8 months ago

This was fixed by #264 and included in the new 0.12.0 release.