UpCloudLtd / terraform-provider-upcloud

Terraform provider for UpCloud
https://registry.terraform.io/providers/UpCloudLtd/upcloud
MIT License
60 stars 31 forks source link

ip_address is set to null when adding new interface #646

Open Xartos opened 3 weeks ago

Xartos commented 3 weeks ago

The problem

I'm having the following script in a upcloud_server

network_interface {
  type    = "private"
  network = upcloud_network.private.id
}

dynamic "network_interface" {
  for_each =  var.use_public_ips ? [1] : []

  content {
    type = "public"
  }
}

When the server is created with both the interfaces all the addresses is (known after apply) i.e.

+ network_interface {
    + bootable            = false
    + ip_address          = (known after apply)
    + ip_address_family   = "IPv4"
    + ip_address_floating = (known after apply)
    + mac_address         = (known after apply)
    + network             = (known after apply)
    + source_ip_filtering = true
    + type                = "private"
  }
+ network_interface {
    + bootable            = false
    + ip_address          = (known after apply)
    + ip_address_family   = "IPv4"
    + ip_address_floating = (known after apply)
    + mac_address         = (known after apply)
    + network             = (known after apply)
    + source_ip_filtering = true
    + type                = "public"
  }

However, if you create the server with only one interface and then add the public interface after the server is created, the ip_address field doesn't get set.

+ network_interface {
    + bootable            = false
    + ip_address_family   = "IPv4"
    + source_ip_filtering = true
    + type                = "public"
  }

This causes some dependencies to not properly work right away since this means that ip_address is set to null. So you need to run the script again for the ip_address to have been assigned and thus usable.

Expected behaviour

I'd expect the ip_address field to always be (known after apply) even when you add the interface to the server after initial creation such that dependencies will wait for the ip_address to be assigned before it's updated.

Environment info

Tested on module version v5.9.1 and v5.10.1 using terraform v1.6.3 and v1.9.6

villevsv-upcloud commented 3 weeks ago

Hi, thanks for reaching out.

We will look into the issue you have described and keep you posted here.