Create an incus instance using OpenTofu
Dahux December 18, 2024 #Incus #OpentofuIt is relatively simple to create an Incus instance using OpenTofu.
This assumes that Incus client is installed on the machine where OpenTofu is running and a current remote server is configured within this client.
Here is a simple main.tf
file:
terraform {
required_providers {
incus = {
source = "lxc/incus"
}
}
}
provider "incus" {
}
resource "incus_instance" "dns-1" {
name = "dns-1"
image = "images:debian/12/cloud"
config = {
"boot.autostart" = true
"limits.cpu" = 1
}
}
Executing the plan
command, produces the result below
Result:
OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
OpenTofu will perform the following actions:
# incus_instance.dns-1 will be created
+ resource "incus_instance" "dns-1" {
+ config = {
+ "boot.autostart" = "true"
+ "limits.cpu" = "1"
}
+ ephemeral = false
+ image = "images:debian/12/cloud"
+ ipv4_address = (known after apply)
+ ipv6_address = (known after apply)
+ mac_address = (known after apply)
+ name = "dns-1"
+ profiles = [
+ "default",
]
+ running = true
+ status = (known after apply)
+ target = (known after apply)
+ type = "container"
+ wait_for_network = true
}
Plan: 1 to add, 0 to change, 0 to destroy.
Executing the apply
command, produces the result below
Result:
OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
OpenTofu will perform the following actions:
# incus_instance.dns-1 will be created
+ resource "incus_instance" "dns-1" {
+ config = {
+ "boot.autostart" = "true"
+ "limits.cpu" = "1"
}
+ ephemeral = false
+ image = "images:debian/12/cloud"
+ ipv4_address = (known after apply)
+ ipv6_address = (known after apply)
+ mac_address = (known after apply)
+ name = "dns-1"
+ profiles = [
+ "default",
]
+ running = true
+ status = (known after apply)
+ target = (known after apply)
+ type = "container"
+ wait_for_network = true
}
Plan: 1 to add, 0 to change, 0 to destroy.
incus_instance.dns-1: Creating...
incus_instance.dns-1: Creation complete after 6s [name=dns-1]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Executing the show
command produces the result below:
Result:
# incus_instance.dns-1:
resource "incus_instance" "dns-1" {
config = {
"boot.autostart" = "true"
"limits.cpu" = "1"
}
ephemeral = false
image = "images:debian/12/cloud"
ipv4_address = "10.0.10.241"
ipv6_address = "2001:db8::216:3eff:fe51:a36a"
mac_address = "00:16:3e:51:a3:6a"
name = "dns-1"
profiles = [
"default",
]
running = true
status = "Running"
type = "container"
wait_for_network = true
}