Skip to content

[Bug]: hcloud_server labels output drift #1340

Description

@astephanh

What happened?

terraform plan will show labels drift after creating server without labels, when labels are defined in output

What did you expect to happen?

no drift

Please provide a minimal working example

output "server" {
  value = hcloud_server.node1
}

resource "hcloud_network" "network" {
  name     = "network"
  ip_range = "10.0.0.0/16"
}

resource "hcloud_network_subnet" "subnet1" {
  network_id   = hcloud_network.network.id
  type         = "cloud"
  network_zone = "eu-central"
  ip_range     = "10.0.1.0/24"
}

resource "hcloud_server" "node1" {

  image       = "debian-12"
  location    = "fsn1"
  name        = "tf-test"
  server_type = "cx33"

  public_net {
    ipv4_enabled = false
    ipv6_enabled = false
  }

  network {
    network_id = hcloud_network.network.id
    alias_ips  = []
  }

}

terraform {
  required_version = ">= 1.12"

  required_providers {
    hcloud = {
      source  = "hetznercloud/hcloud"
      version = ">= 1.60"
    }
  }
}

terraform plan after terraform apply will show:

hcloud_network.network: Refreshing state... [id=11910270]
hcloud_network_subnet.subnet1: Refreshing state... [id=11910270-10.0.1.0/24]
hcloud_server.node1: Refreshing state... [id=120135417]

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply" which may have affected
this plan:

  # hcloud_server.node1 has changed
  ~ resource "hcloud_server" "node1" {
        id                         = "120135417"
      + labels                     = {}
        name                       = "tf-test"
        # (19 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }


Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the
following plan may include actions to undo or respond to these changes.

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Changes to Outputs:
  ~ server = {
        id                         = "120135417"
      ~ labels                     = null -> {}
        name                       = "tf-test"
        # (26 unchanged attributes hidden)
    }

You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions