Skip to content

upcloud_loadbalancer individual nodes not accessible in output #778

@avaly

Description

@avaly

Using upcloud_loadbalancer with public & private networks, the output of the public IP address can't be read in an output field:

resource "upcloud_network" "lb_network" {
  ...
}
resource "upcloud_loadbalancer" "lb" {
  name = "lb-test"
  plan = "development"
  zone = var.lb_zone
  networks {
    name   = "Public-Net"
    type   = "public"
    family = "IPv4"
  }
  networks {
    name    = "Private-Net"
    type    = "private"
    family  = "IPv4"
    network = resource.upcloud_network.lb_network.id
  }
}
output "load_balancer_ip_public" {
  value = upcloud_loadbalancer.lb.nodes[0].networks[0].ip_addresses[0].address
}

Throws the following error by Terraform:

│ Error: Invalid index
│ 
│   on cluster.tf line 161, in output "load_balancer_ip_public":
│  161:   value = upcloud_loadbalancer.lb.nodes[0].networks[0].ip_addresses[0].address
│ 
│ This value does not have any indices.

But changing the value of the output to just upcloud_loadbalancer.lb.nodes, prints the following plan:

Changes to Outputs:
  + load_balancer_ip_public = [
      + {
          + networks          = [
              + {
                  + ip_addresses = [
                      + {
                          + address = "REDACTED"
                          + listen  = true
                        },
                    ]
                  + name         = "Public-Net"
                  + type         = "public"
                },
              + {
                  + ip_addresses = [
                      + {
                          + address = "10.0.0.3"
                          + listen  = false
                        },
                      + {
                          + address = "10.0.0.4"
                          + listen  = true
                        },
                    ]
                  + name         = "Private-Net"
                  + type         = "private"
                },
            ]
          + operational_state = "running"
        },
    ]

So it seems to be a list of records. But as soon as we add [0] after the .nodes, we get:

│ Error: Invalid index
│ 
│   on cluster.tf line 161, in output "load_balancer_ip_public":
│  161:   value = upcloud_loadbalancer.main.nodes[0]
│ 
│ This value does not have any indices.

I'm using the v5.22.1 version of the provider.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions