terraform-provider-hcloud icon indicating copy to clipboard operation
terraform-provider-hcloud copied to clipboard

[Bug]: After importing hcloud_server terraform plan is showing fields to be updated

Open phoewass opened this issue 8 months ago • 4 comments

What happened?

I created a terraform hcloud_server to import my server that I created manually.
Then I import it: terraform import hcloud_server.my_server XXXXXXX

It works fine but when I execute terraform plan I see this result:

hcloud_server.my_server: Refreshing state... [id=XXXXXXX]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # hcloud_server.my_server will be updated in-place
  ~ resource "hcloud_server" "my_server" {
      + allow_deprecated_images    = false
      ~ delete_protection          = true -> false
        id                         = "XXXXXXX"
      + ignore_remote_firewall_ids = false
      + keep_disk                  = false
        name                       = "xxxxxxxxxxxx"
      ~ rebuild_protection         = true -> false
      ~ server_type                = "cpx11" -> "cxp11"
      + shutdown_before_deletion   = false
        # (13 unchanged attributes hidden)

      + public_net {
          + ipv4         = (known after apply)
          + ipv4_enabled = true
          + ipv6         = (known after apply)
          + ipv6_enabled = true
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

What did you expect to happen?

terraform plan should show:

No changes. Your infrastructure matches the configuration.

Looking at "terraform.tfstate" file after import, everything looks fine:

{
  "resources": [
    {
      "instances": [
        {
          "attributes": {
            ..
            "delete_protection": true,
            ..
            "rebuild_protection": true,
            ..
            "server_type": "cpx11",

Please provide a minimal working example

terraform: 1.8.4 hetznercloud/hcloud: 1.47

resource "hcloud_server" "my_server" {
  name                = "xxxxxxxxxxxx"
  image               = "ubuntu-20.04"
  server_type         = "cxp11"

  public_net {
    ipv4_enabled = true
    ipv6_enabled = true
  }
}
  1. terraform import hcloud_server.my_server XXXXXXX

  2. terraform plan

phoewass avatar Jun 27 '24 11:06 phoewass