0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-08-22 11:28:33 +00:00
terraform-provider-proxmox/example/resource_virtual_environment_container.tf
k69420s 45f28051cd
feat(lxc): add proxmox_virtual_environment_containers data source (#2090)
* feat(lxc): add `proxmox_virtual_environment_containers` data source

- Implements a new data source for fetching container details in Proxmox environments.
- Includes support for filtering by attributes such as name, template, status, and tags.
- Provides documentation and test coverage for the new functionality.

Signed-off-by: k69420s <k69420s@localhost.localdomain>

* suppress duplication error in linter, fix example code

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>

---------

Signed-off-by: k69420s <k69420s@localhost.localdomain>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
2025-08-14 18:26:47 -04:00

101 lines
2.0 KiB
HCL

resource "proxmox_virtual_environment_container" "example_template" {
description = "Managed by Terraform"
start_on_boot = "true"
disk {
datastore_id = var.virtual_environment_storage
size = 4
}
mount_point {
// volume mount
volume = var.virtual_environment_storage
size = "4G"
path = "mnt/local"
}
initialization {
dns {
servers = ["1.1.1.1", "8.8.8.8"]
}
hostname = "terraform-provider-proxmox-example-lxc-template"
ip_config {
ipv4 {
address = "dhcp"
}
}
user_account {
keys = [trimspace(tls_private_key.example.public_key_openssh)]
password = "example"
}
}
network_interface {
name = "veth0"
mtu = 1450
}
node_name = data.proxmox_virtual_environment_nodes.example.names[0]
operating_system {
template_file_id = proxmox_virtual_environment_download_file.release_20250701_ubuntu_24_10_lxc_img.id
type = "ubuntu"
}
pool_id = proxmox_virtual_environment_pool.example.id
template = true
// use auto-generated vm_id
tags = [
"container",
"example",
"terraform",
]
startup {
order = "3"
up_delay = "60"
down_delay = "60"
}
}
resource "proxmox_virtual_environment_container" "example" {
disk {
datastore_id = var.virtual_environment_storage
}
clone {
vm_id = proxmox_virtual_environment_container.example_template.id
}
tags = [
"container",
]
initialization {
hostname = "terraform-provider-proxmox-example-lxc"
}
mount_point {
// bind mount, requires root@pam
volume = "/mnt/bindmounts/shared"
path = "/shared"
}
node_name = data.proxmox_virtual_environment_nodes.example.names[0]
pool_id = proxmox_virtual_environment_pool.example.id
# Set the protection flag to prevent the deletion/update operations for the container and its disks.
# protection = true
vm_id = 2043
}
output "resource_proxmox_virtual_environment_container_example_id" {
value = proxmox_virtual_environment_container.example.id
}