Skip to content

Data Source: proxmox_files

Retrieves a list of files available in a datastore on a specific Proxmox VE node.

Example Usage

data "proxmox_files" "iso_files" {
  node_name    = "pve"
  datastore_id = "local"
  content_type = "iso"
}

# Check if a specific image already exists
locals {
  image_exists = anytrue([
    for f in data.proxmox_files.iso_files.files :
    f.file_name == "noble-server-cloudimg-amd64.img"
  ])
}

# Only download if the image doesn't already exist
resource "proxmox_virtual_environment_download_file" "ubuntu_noble" {
  count = local.image_exists ? 0 : 1

  datastore_id = "local"
  node_name    = "pve"
  content_type = "iso"
  url          = "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
}

# List all files without filtering
data "proxmox_files" "all_files" {
  node_name    = "pve"
  datastore_id = "local"
}

output "iso_file_count" {
  value = length(data.proxmox_files.iso_files.files)
}

output "all_file_names" {
  value = [for f in data.proxmox_files.all_files.files : f.file_name]
}

Schema

Required

Optional

  • content_type (String) The content type to filter by. When set, only files of this type are returned. Valid values are backup, images, import, iso, rootdir, snippets, vztmpl.

Read-Only

Nested Schema for files

Read-Only:

  • content_type (String) The content type of the file.
  • file_format (String) The format of the file.
  • file_name (String) The name of the file.
  • file_size (Number) The size of the file in bytes.
  • id (String) The unique identifier of the file (volume ID), e.g. local:iso/ubuntu.iso.
  • vmid (Number) The VM ID associated with the file, if applicable.