terraform-provider-hcloud
terraform-provider-hcloud copied to clipboard
[Bug]: ipv4_address & ipv6_address on server resource are not updated correctly
What happened?
When adding/removing a primary IP through hcloud_server.public_net.ipv4/6_enabled
the updated values in hcloud_server.ipv4/6_address
are only visible after a second apply.
Bug demoed here: https://asciinema.org/a/9vjHZx6bEq3RoWYTZ1EbftUEu
What did you expect to happen?
Expected the changes to be visible immediatly after adding/removing the address.
Please provide a minimal working example
Can be observed with this config and then toggling the ipv6
address on and off, output should change with a 1 apply "delay":
resource "hcloud_server" "tf_687" {
server_type = "cax11"
name = "tf-687"
image = "ubuntu-22.04"
location = "fsn1"
public_net {
ipv4_enabled = true
ipv6_enabled = false
}
}
output "ipv6" {
value = hcloud_server.tf_687.ipv6_address
}
For easier debugging, these changes to the e2e test also exhibit the broken behaviour:
diff --git a/internal/e2etests/server/resource_test.go b/internal/e2etests/server/resource_test.go
index d6a5934e..02a1edfd 100644
--- a/internal/e2etests/server/resource_test.go
+++ b/internal/e2etests/server/resource_test.go
@@ -605,9 +605,15 @@ func TestServerResource_PrimaryIPNetworkTests(t *testing.T) {
resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "network.#", "1"),
resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "network.0.ip", "10.0.1.5"),
resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "network.0.alias_ips.#", "2"),
+ resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "ipv4_address", s.PublicNet.IPv4.IP.String()),
+ resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "ipv6_address", s.PublicNet.IPv6.IP.String()+"1"),
testsupport.LiftTCF(func() error {
assert.NotEqual(t, 0, s.PublicNet.IPv4.ID)
assert.NotEqual(t, 0, s.PublicNet.IPv6.ID)
+
+ // Make sure that public IPs are actually set
+ assert.NotEqual(t, "<nil>", s.PublicNet.IPv4.IP.String())
+ assert.NotEqual(t, "<nil>", s.PublicNet.IPv6.IP.String())
return nil
}),
),
@@ -627,6 +633,8 @@ func TestServerResource_PrimaryIPNetworkTests(t *testing.T) {
resource.TestCheckResourceAttr(sResWithoutPublicNet.TFID(), "network.#", "1"),
resource.TestCheckResourceAttr(sResWithoutPublicNet.TFID(), "network.0.ip", "10.0.1.5"),
resource.TestCheckResourceAttr(sResWithoutPublicNet.TFID(), "network.0.alias_ips.#", "2"),
+ resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "ipv4_address", "<nil>"),
+ resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "ipv6_address", "<nil>"),
testsupport.LiftTCF(func() error {
assert.Nil(t, s.PublicNet.IPv4.IP)
assert.Nil(t, s.PublicNet.IPv6.IP)
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.