You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the terraform import command to get an existing VM from Xen Orchestra works. However, when showing the resource with terraform state show and copying the resulting output to the test-vm-01.tf file, adding the required template value and removing the dynamic values from the state shows inconsistencies when running terraform plan, making it basically impossible to import an existing infrastructure.
echo -e 'resource "xenorchestra_vm" "test-vm-01" {
# Will be imported
}' > ./test-vm-01.tf
terraform import xenorchestra_vm.test-vm-01 12d0b1ed-5a63-d3b4-3ed8-a8f165f2c36b
# command successfully completes "Import successful!"
terraform state show xenorchestra_vm.test-vm-01
This is also the case when using the experimental -generate-config-out flag for terraform plan (reset state, not containing test-vm-01).
echo -e 'import {
to = xenorchestra_vm.test-vm-01
id = "12d0b1ed-5a63-d3b4-3ed8-a8f165f2c36b"
}' > import.tf
terraform plan -generate-config-out=generated.tf
cat generated.tf
The generate command seems to work, except for it not adding the correct template value. Output: terraform_plan_generate.txt
Adding the template vauluet manually, the generated.tf file looks as follows: generated.tf.txt
Then running terraform plan shows basically the same error: terraform_plan_generated.txt
The only other option I found was the terraformer tool which has a community supported xenorchestra plugin. But it unfortunately doesn't support importing VMs.
Edit: Forgot to mention, using the same .tf file copied from the state to create a new VM works without any issues and produces a matching state so that terraform plan reports "No changes.".
The text was updated successfully, but these errors were encountered:
Using the
terraform import
command to get an existing VM from Xen Orchestra works. However, when showing the resource withterraform state show
and copying the resulting output to the test-vm-01.tf file, adding the required template value and removing the dynamic values from the state shows inconsistencies when runningterraform plan
, making it basically impossible to import an existing infrastructure.Output of
state show
command: test-vm-01_state_show.txtConverted to the following
.tf
file: test-vm-01.tf.txtProduces the following
terraform plan
state difference which requires the vm to be recreated: terraform_plan.txtThis is also the case when using the experimental
-generate-config-out
flag forterraform plan
(reset state, not containing test-vm-01).The generate command seems to work, except for it not adding the correct template value. Output: terraform_plan_generate.txt
Adding the template vauluet manually, the
generated.tf
file looks as follows: generated.tf.txtThen running terraform plan shows basically the same error: terraform_plan_generated.txt
The only other option I found was the terraformer tool which has a community supported xenorchestra plugin. But it unfortunately doesn't support importing VMs.
Edit: Forgot to mention, using the same
.tf
file copied from the state to create a new VM works without any issues and produces a matching state so thatterraform plan
reports "No changes.".The text was updated successfully, but these errors were encountered: