Hi
I’m new to the Terraform azure provider and is having an issue when creating windows VM with data disks.
After creating and attaching the disks i need to log on to the VM and run disk manager to initialize and create drives.
Is there a way to do this automatically?
This is an example snippet of the main.tf file:
resource "azurerm_managed_disk" "example" {
name = "example-disc1"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
storage_account_type = "Standard_LRS"
disk_size_gb = 64
create_option = "Empty"
}
resource "azurerm_virtual_machine_data_disk_attachment" "example" {
managed_disk_id = azurerm_managed_disk.example.id
virtual_machine_id = azurerm_windows_virtual_machine.example.id
lun = "0"
caching = "ReadWrite"
create_option = "Attach"
}
resource "azurerm_windows_virtual_machine" "example" {
name = "example-machine"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
size = "Standard_D2s_v3"
admin_username = "adminuser"
admin_password = "P@$$w0rd1234!"
network_interface_ids = [
azurerm_network_interface.example.id,
]
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
sku = "2019-Datacenter"
version = "latest"
}
}