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

vhd resource not stateful #126

Open
rdvansloten opened this issue May 5, 2022 · 3 comments
Open

vhd resource not stateful #126

rdvansloten opened this issue May 5, 2022 · 3 comments
Labels

Comments

@rdvansloten
Copy link

rdvansloten commented May 5, 2022

Terraform Version

1.1.9

Provider Settings

1.0.3

provider "hyperv" {
  user        = "username"
  password    = "password"
  host        = "server"
  port        = 5986
  https       = true
  insecure    = true
  use_ntlm    = true
  script_path = "C:/Temp/terraform_%RAND%.cmd"
  timeout     = "30s"
}

Affected Resource(s)

  • hyperv_vhd

Terraform Configuration Files

resource "hyperv_vhd" "web_server_vhd" {
  path     = "R:\\Disks\\LinuxVM.vhdx"
  vhd_type = "Dynamic"
  size     = 21474836480
}

Debug Output

Terraform will perform the following actions when changing the name:

 ~ resource "hyperv_vhd" "web_server_vhd" {
      ~ exists               = false -> (known after apply)
        id                   = "R:\\Disks\\LinuxVM.vhdx"
      ~ path                 = "R:\\Disks\\LinuxVM.vhdx" -> "R:\\Disks\\LinuxVM01.vhdx"
        # (5 unchanged attributes hidden)
    }

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

When not changing anything at all:

# hyperv_vhd.web_server_vhd will be updated in-place
  ~ resource "hyperv_vhd" "vhd" {
      ~ exists               = false -> (known after apply)
        id                   = "R:\\Disks\\LinuxVM.vhdx"
        # (7 unchanged attributes hidden)
    }

Expected Behavior

  • LinuxVM.vhdx should have been destroyed and LinuxVM01.vhdx should have been created in its place.
  • When I don't make a change, Terraform should not modify the disk

Actual Behavior

  • Both .vhdx files now exist:
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----          5-5-2022     21:06        4194304 LinuxVM.vhdx
-a----          5-5-2022     21:08        4194304 LinuxVM01.vhdx
  • Terraform calls an "exist" field and modifies the resource each run

When the entire vhd resource block is removed, the disk will be deleted upon the next terraform apply, as expected.

Steps to Reproduce

Use the config above, terraform init + apply

@dmirallestl
Copy link

Reproduced. I got a workarround by ignoring_changes on exists but this should be fixed to avoid the patch.

@taliesins taliesins added the bug label Dec 14, 2022
@taliesins
Copy link
Owner

Should the vhd be renamed it should we be deleting the vhdx. Get complicated when VHDX has snapshots.

@tgbgb
Copy link

tgbgb commented Jan 27, 2023

I also have this issue.

Every time i run terraform apply the disk shows as being updated in place even though no changes were made

image

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

4 participants