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

proxmox_virtual_environment_user_token does not work with privilege_separation = false #1641

Closed geoffreytran closed 1 week ago

geoffreytran commented 1 week ago

Describe the bug When privilege_separation is disabled, the resource returns a null token. In addition the second issue is the resource is missing the ability to set acls for when the default privilege_separate is enabled

To Reproduce Steps to reproduce the behavior:

# Create a new role and user for the CSI plugin
resource "proxmox_virtual_environment_role" "csi" {
  role_id    = "CSI"

  privileges = [
    "VM.Audit",
    "VM.Config.Disk",
    "Datastore.Allocate",
    "Datastore.AllocateSpace",
    "Datastore.Audit"
  ]
}

resource "proxmox_virtual_environment_user" "kubernetes_csi" {
  user_id  = "kubernetes-csi@pve"
  comment  = "Managed by Terraform"

  acl {
    path      = "/"
    propagate = true
    role_id   = proxmox_virtual_environment_role.csi.role_id
  }
}

resource "proxmox_virtual_environment_user_token" "kubernetes_csi_token" {
  comment         = "Managed by Terraform"
  expiration_date = "2033-01-01T22:00:00Z"
  token_name      = "kubernetes-csi-token"
  user_id         = proxmox_virtual_environment_user.kubernetes_csi.user_id

  privileges_separation = false
}
geoffreytran commented 1 week ago

User error, looks like the resource doesn't handle changing the attribute after it has been created. It causes the token values to be reset to null.