From 0cf0c669f4a4b7277962d140e3000fa8c0038ff4 Mon Sep 17 00:00:00 2001 From: Keith Jackson Date: Fri, 28 Aug 2026 11:22:06 -0500 Subject: [PATCH] tofu: migrate to non-deprecated proxmox_download_file (ADR-007) bpg/proxmox deprecates proxmox_virtual_environment_download_file ("Use proxmox_download_file instead. This resource will be removed in v1.0."), the short-name rename from ADR-007. Both are the same dual-registered Framework resource, so rename the resource type + import_from reference and add a `moved` block. OpenTofu 1.9 drives the provider's MoveState (migration.PrefixMoveState) to transfer state in place: same id, no re-download of the Debian image, no change to the VMs. Co-Authored-By: Claude Opus 4.8 --- infra/tofu/main.tf | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/infra/tofu/main.tf b/infra/tofu/main.tf index cf61a8d..cfa2f5d 100644 --- a/infra/tofu/main.tf +++ b/infra/tofu/main.tf @@ -40,7 +40,14 @@ locals { # OPERATOR ACTION: enable the "Import" content type on var.image_datastore (Datacenter # -> Storage -> local -> Content -> check "Import"), else the disk import fails with # "wrong type 'iso' - needs to be 'images' or 'import'". -resource "proxmox_virtual_environment_download_file" "debian_cloud_image" { +# +# Resource type is the SHORT name `proxmox_download_file` (bpg/proxmox ADR-007). The old +# `proxmox_virtual_environment_download_file` is deprecated ("Use `proxmox_download_file` +# instead. This resource will be removed in v1.0.") — both are the same dual-registered +# Framework resource, so the schema is identical. The `moved` block below migrates existing +# state in place (provider implements MoveState / migration.PrefixMoveState), so no +# re-download of the image and no change to the VMs. +resource "proxmox_download_file" "debian_cloud_image" { content_type = "import" datastore_id = var.image_datastore node_name = var.proxmox_node @@ -49,6 +56,15 @@ resource "proxmox_virtual_environment_download_file" "debian_cloud_image" { overwrite = false } +# State migration for the deprecated -> short resource-type rename (ADR-007). OpenTofu +# 1.9 (>= 1.8 required) drives the provider's MoveState RPC: the download_file state is +# transferred in place, keeping the same id (datastore_id:content_type/file_name), so the +# already-downloaded Debian image is NOT re-downloaded and the VMs' import_from is unchanged. +moved { + from = proxmox_virtual_environment_download_file.debian_cloud_image + to = proxmox_download_file.debian_cloud_image +} + # --- cloud-init: NATIVE Proxmox cloud-init only (API-driven) ------------------ # The rich first-boot baseline (packages, kernel modules, Longhorn disk, swap-off) # is NOT delivered as a custom snippet any more — custom snippets require SSH/SFTP @@ -102,7 +118,7 @@ resource "proxmox_virtual_environment_vm" "node" { # fs_setup/mount for /var/lib/longhorn already expects. disk { datastore_id = var.datastore - import_from = proxmox_virtual_environment_download_file.debian_cloud_image.id + import_from = proxmox_download_file.debian_cloud_image.id interface = "virtio0" size = var.os_disk_gib discard = "on"