Hi there,
I am using azurerm_virtual_machine_extension to join my VM’s to the domain. Is there a way that i can use this extension to delete the computer object on destroy? Or is there any other way of doing this on destroy only?
Thanks.
resource "azurerm_virtual_machine_extension" "join-domain" {
count = var.join_domain ? 1 : 0
name = "join-domain"
virtual_machine_id = azurerm_windows_virtual_machine.vm.id
publisher = "Microsoft.Compute"
type = "JsonADDomainExtension"
type_handler_version = "1.3"
settings = <<SETTINGS
{
"Name": "${var.active_directory_domain}",
"OUPath": "${var.oupath}",
"User": "${var.active_directory_netbios_domain}\\${var.active_directory_username}",
"Restart": "true",
"Options": "3"
}
SETTINGS
protected_settings = <<PROTECTED_SETTINGS
{
"Password": "${var.active_directory_password}"
}
PROTECTED_SETTINGS
depends_on = [azurerm_windows_virtual_machine.vm]
}