Due to https://github.com/hashicorp/terraform-provider-azurerm/issues/6117, I must use azurerm_virtual_machine to create my intended machine.
Unfortunately, the image in use requires trusted launch, for which I could not find any configuration option.
Is this possible or am I forced to use az_api instead?
2
Answers
As it seems not possible with azurerm, I ended up doing it with terraform_data.
As the image I'm using defines managed data disks, I had to extend the cleanup accordingly. My code looks like this:
Beware that only the relevant code for the vm is posted and may required adaptations for specific needs. Additionally, the hostname is set randomly to prevent machines with the same name trying to join AAD. Also beware to add all inputs which should force a recreation of the resource.
Here is the
Terraform
script to create a Virtual Machine with Trusted Launch configuration using the azurerm module. For Azapi, refer to the MS DocOutput: