Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ip_address is set to null when adding new interface #646

Open
Xartos opened this issue Oct 1, 2024 · 2 comments
Open

ip_address is set to null when adding new interface #646

Xartos opened this issue Oct 1, 2024 · 2 comments
Labels

Comments

@Xartos
Copy link

Xartos commented Oct 1, 2024

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
Copy link
Contributor

Hi, thanks for reaching out.

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

@kangasta
Copy link
Contributor

kangasta commented Nov 4, 2024

Hi, this likely happens because of a limitation in how Terraform plugin SDK handles nested computed values: hashicorp/terraform-plugin-sdk#459.

This should be fixed when we migrate the server resource to Terraform plugin framework, which allows us to mark that field as unknown when computing the plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants