bpg / terraform-provider-proxmox

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

Add TPM supports to VM crash #1640

Closed bobbylewiss closed 10 hours ago

bobbylewiss commented 1 week ago

Describe the bug

Hello, I'm new here and trying to use your provider, which is really nice btw (before i used telmate). I have found a little issue on the documentation in main/docs/resources/virtual_environment_vm.md for tpm state :

  tpm_state { (optional)
    datastore_id = "local" (optional) --> must be mandatory
    version = "v2.0" (optional)
  }

If datastore_id is not set this will cause an error and destroy your vm if it's stopped.

Thank you for your great work !

To Reproduce

  1. Add tpm_state to your main.tf :
    tpm_state {
    version = "v2.0"
    }
  2. terraform plan && terraform apply --auto-approve
  3. Will prompt you this :
    │ Error: error creating VM: All attempts fail:
    │ #1: the requested resource does not exist
    │ #2: the requested resource does not exist
    │ #3: the requested resource does not exist
    │
    │   with proxmox_virtual_environment_vm.test,
    │   on main.tf line 3, in resource "proxmox_virtual_environment_vm" "test":
    │    3: resource "proxmox_virtual_environment_vm" "test" {
    │
  4. VM in proxmox will be destroyed

Expected behavior It would be nice to have a gate keeper that says watch out, datastore_id is required, before applying and destroying your vm.

Additional context

bpg commented 1 day ago

Hey @bobbylewiss 👋🏼

Your PVE host probably does not have local-lvm datastore set up, as this is the default value of datastore_id in the tpm_state resource.

Could you confirm if this is the case?

If it is, I would argue that this is not an issue, but rather an expected behaviour, as all defaults are catered to a straightforward PVE setup with LVM storage.

bobbylewiss commented 10 hours ago

You are right, i'm not using local-lvm by default. Something I need to watchout. But its still weird to destroy the running vm... Thank you and keep the good work !