@michael132 First post so hopefully I don't mess up the formatting too bad.
I did the import with openTofu (AFAIK it's identical to terraform since it uses the terraform provider behind the scenes).
After import I got some fields during "plan" action that said it would need to be recreated
I followed the blogpost here:
https://xen-orchestra.com/blog/managing-existing-infrastructure-with-terraform-2/
the 2 offending fields for me was:
- template
- destroy_cloud_config_vdi_after_boot
so I added the small lifecycle part in the bottom and now "plan" is agreeing with the configured infrastructure.
I also added some math for memory and disk to make it easier to see how many GB it is easier.
resource "xenorchestra_vm" "imported" {
template = "template"
auto_poweron = true
cpus = 2
exp_nested_hvm = false
hvm_boot_firmware = "bios"
memory_max = 4*1073741824
name_description = "k8s-clu01-01"
name_label = "K8S-clu01-01"
start_delay = 0
tags = [
"k8s-clu-01",
]
cdrom {
id = "some-cdrom-id"
}
disk {
attached = true
name_description = "Created by XO"
name_label = "Debian Bookworm 12_evibo"
size = 50*1073741824
sr_id = "some-sr-id"
}
network {
attached = true
mac_address = "de:ad:be:ef"
network_id = "some-network-id"
}
lifecycle {
ignore_changes = [
template,
destroy_cloud_config_vdi_after_boot,
]
}
}