bpg / terraform-provider-proxmox

Terraform Provider for Proxmox
https://registry.terraform.io/providers/bpg/proxmox
Mozilla Public License 2.0
805 stars 134 forks source link

Sort tags #742

Closed rgl closed 10 months ago

rgl commented 10 months ago

Describe the bug

The tags does not seem to be sorted before being compared by the plan, which leads to a terraform plan diff off:

-/+ resource "proxmox_virtual_environment_vm" "example" {
      ~ tags                    = [
          + "windows-2022-uefi",
            "example",
            "terraform",
          - "windows-2022-uefi",
        ]

To Reproduce Steps to reproduce the behavior:

  1. Create a resource 'proxmox_virtual_environment_vm'
  2. Run 'terraform apply'
  3. Modify the resource 'proxmox_virtual_environment_vm' in a way that makes it be recreated (this seems to trigger tags shuffle).
  4. Run 'terraform apply'
  5. see the plan/apply diff tags showing the bogus tags difference.

Expected behavior Since I did not change the tags, they should no appear as different in the terraform plan diff.

Additional context Add any other context about the problem here.

zimmertr commented 10 months ago

This is documented here with a suggested workaround.

bpg commented 10 months ago

It also supposed to be fixed by #322, so I'm quite puzzled why it is still reproducible in this use case 🤔

bpg commented 10 months ago

can't reproduce on my minimal template with PVE 8.1.3:

resource "proxmox_virtual_environment_vm" "test" {
  name      = "test"
  node_name = "pve"

  tags = [
    "windows-2022-uefi",
    "example",
    "terraform",
  ]

  started  = falsee
}
❯ terraform apply -auto-approve
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - bpg/proxmox in /Users/user/go/bin
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with
│ published releases.
╵

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # proxmox_virtual_environment_vm.test will be created
  + resource "proxmox_virtual_environment_vm" "test" {
      + acpi                    = true
      + bios                    = "seabios"
      + id                      = (known after apply)
      + ipv4_addresses          = (known after apply)
      + ipv6_addresses          = (known after apply)
      + keyboard_layout         = "en-us"
      + mac_addresses           = (known after apply)
      + migrate                 = false
      + name                    = "test"
      + network_interface_names = (known after apply)
      + node_name               = "pve"
      + on_boot                 = true
      + reboot                  = false
      + scsi_hardware           = "virtio-scsi-pci"
      + started                 = false
      + tablet_device           = true
      + tags                    = [
          + "windows-2022-uefi",
          + "example",
          + "terraform",
        ]
      + template                = false
      + timeout_clone           = 1800
      + timeout_create          = 1800
      + timeout_migrate         = 1800
      + timeout_move_disk       = 1800
      + timeout_reboot          = 1800
      + timeout_shutdown_vm     = 1800
      + timeout_start_vm        = 1800
      + timeout_stop_vm         = 300
      + vm_id                   = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.
proxmox_virtual_environment_vm.test: Creating...
proxmox_virtual_environment_vm.test: Creation complete after 6s [id=100]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
❯ terraform apply -auto-approve
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - bpg/proxmox in /Users/user/go/bin
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with
│ published releases.
╵
proxmox_virtual_environment_vm.test: Refreshing state... [id=100]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
bpg commented 10 months ago

Unable to reproduce on v0.41.0, and no further comments from the author, so closing. @rgl, please feel free to reopen with new details.