resource "proxmox_lxc" "app_container" {
  for_each = var.containers

  target_node = var.target_node
  hostname    = each.key
  ostemplate  = var.ostemplate
  password    = "password"

  ssh_public_keys = var.ssh_public_key

  cores  = var.lxc_resources.cores
  memory = var.lxc_resources.memory
  swap   = var.lxc_resources.swap

  rootfs {
    storage = var.storage
    size    = var.size
  }

  network {
    name     = "eth0"
    bridge   = var.bridge
    ip       = each.value.ip
    gw       = var.gateway
    firewall = true
  }

  start = true

  connection {
    type        = "ssh"
    host        = trimsuffix(each.value.ip, "/24")
    user        = "root"
    private_key = var.private_key
    timeout     = "2m"
  }


}
