terraform-provider-proxmox
terraform-provider-proxmox copied to clipboard
Add support for `proxmox_virtual_environment_file` data source
Not a bug, just need help to use the provider, maybe it's more terraform usage than provider help, feel free to close this issue if it's not appropriate.
In my usage, I separate each VM in directory but I want to use the same iso/vztmpl.
For now, I have a common directory with terraform configuration to download iso/vztmpl with proxmox_virtual_environment_download_file resource:
resource "proxmox_virtual_environment_download_file" "ubuntu_2204_cloud_image" {
content_type = "iso"
datastore_id = var.image_datastorestore_id
node_name = var.node_name
overwrite = false
url = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
}
Then in each VM directories I import them like this:
import {
to = proxmox_virtual_environment_file.ubuntu_2204_vm_image
id = "${var.node_name}/${var.image_datastorestore_id}:iso/jammy-server-cloudimg-amd64.img"
}
resource "proxmox_virtual_environment_file" "ubuntu_2204_vm_image" {
content_type = "iso"
datastore_id = var.image_datastorestore_id
node_name = var.node_name
overwrite = false
lifecycle {
prevent_destroy = true
}
}
I had to configure lifecycle with prevent_destroy to preserve my image if I destroy VM (so I need to destroy with -targetoption)
Is there a better way (I tought use template but I prefer not) ? In my terraform comprehension this had to be done with data source, but there is no data source for file ?
Thanks for your help
Hi @VoidAndAny 👋🏼
Yeah, the file datasource would make it easier. But you probably don't need to define resource "proxmox_virtual_environment_file" "ubuntu_2204_vm_image" within each VM folder either. You can use "${var.image_datastorestore_id}:iso/jammy-server-cloudimg-amd64.img" directly as a disk.file_id value in the VM.
Whaouh, so simple You can close this issue if you want, thanks a lot
I'll leave it, would be a useful feature.
+1, I need this feature
Marking this issue as stale due to inactivity in the past 180 days. This helps us focus on the active issues. If this issue is reproducible with the latest version of the provider, please comment. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!