It’s obvious when you mention it…
I’ll just post the working tf for completenes as well as link to documentation incus/doc/cloud-init.md at main · lxc/incus · GitHub
terraform {
required_providers {
incus = {
source = "lxc/incus"
}
}
}
provider "incus" {
// Configuration for the Incus provider
}
resource "incus_network" "private" {
name = "private"
config = {
"ipv4.address" = "192.168.170.1/24"
"ipv4.nat" = "true"
"ipv4.dhcp" = "false"
"ipv6.dhcp" = "false"
}
}
resource "incus_profile" "private_profile" {
name = "private_profile"
device {
name = "eth1"
type = "nic"
properties = {
nictype = "bridged"
parent = "${incus_network.private.name}"
}
}
device {
type = "disk"
name = "root"
properties = {
pool = "default"
path = "/"
}
}
}
resource "incus_instance" "testserver" {
name = "testserver"
image = "images:debian/12/cloud"
profiles = ["default", "${incus_profile.private_profile.name}"]
config = {
"boot.autostart" = true
"cloud-init.network-config" = <<-EOT
#cloud-config
version: 2
ethernets:
eth0:
dhcp4: true
dhcp6: true
eth1:
dhcp4: false
dhcp6: false
addresses:
- 192.168.170.50/24
gateway4: 192.168.170.1
EOT
"cloud-init.user-data" = <<-EOT
#cloud-config
timezone: Europe/Stockholm
package_update: true
package_upgrade: true
packages:
- openssh-server
- sudo
EOT
}
limits = {
cpu = 2
}
}