How to access `network` attribute for `hcloud_server`

Looking at the docu the hcloud_server has an attribute network

(map) Private Network the server shall be attached to

However I have troubles to understand how I could extract let’s say the ip

Let’s say I have this


resource "hcloud_network" "net" {
  name     = var.prefix
  ip_range = var.ip_range
}

resource "hcloud_network_subnet" "rancher" {
  network_id   = hcloud_network.net.id
  type         = "cloud"
  network_zone = var.network_zone
  ip_range     = var.ip_range
}

resource "hcloud_server_network" "rancher_server" {
  count     = 1
  server_id = element(hcloud_server.rancher_server.*.id, count.index)
  subnet_id = hcloud_network_subnet.rancher.id
}

# HCLOUD server for creating a single node RKE cluster and installing the Rancher server
resource "hcloud_server" "rancher_server" {
  count       = 1
  name        = "${var.prefix}-rancher-server-${count.index + 1}"
  server_type = var.machine_type
  image       = var.image
  location    = var.datacenter

  ssh_keys = [
    hcloud_ssh_key.rancher.id,
  ]

  network {
      network_id = hcloud_network.net.id
  }
}

I thought this will work

node_internal_ip       = hcloud_server.rancher_server.0.network[hcloud_network.net.id].ip

however this results in

│ Error: Invalid index
│ 
│   on infra.tf line 100, in module "rancher_common":
│  100:   node_internal_ip       = hcloud_server.rancher_server.0.network[hcloud_network.net.id].ip
│     ├────────────────
│     │ hcloud_network.net.id is a string, known only after apply
│     │ hcloud_server.rancher_server[0].network is set of object with 1 element

whereas

node_internal_ip       = hcloud_server.rancher_server.0.network.0.ip
│ Error: Cannot index a set value
│ 
│   on infra.tf line 100, in module "rancher_common":
│  100:   node_internal_ip       = hcloud_server.rancher_server.0.network.0.ip
│ 
│ Block type "network" is represented by a set of objects, and set elements do not have addressable keys. To find elements matching specific criteria, use a "for" expression with an "if" clause.

The solution can be found in this stackflow post:

  node_internal_ip       = hcloud_server.rancher_server.0.network.*.ip[0]