modules/win_vm/main.tf (41 lines of code) (raw):
resource "azurerm_network_interface" "nic" {
name = "nic-${var.vm_name}"
location = var.location
resource_group_name = var.resource_group_name
tags = var.tags
ip_configuration {
name = "internal"
subnet_id = var.contoso_subnet_id
private_ip_address_allocation = "Dynamic"
}
}
resource "random_password" "password" {
length = 16
special = true
override_special = "_%@"
}
# Create the jumpbox VM
resource "azurerm_windows_virtual_machine" "vm" {
name = var.vm_name
location = var.location
resource_group_name = var.resource_group_name
size = "Standard_F2"
admin_username = "azureadmin"
admin_password = random_password.password.result
tags = var.tags
identity {
type = "SystemAssigned"
}
network_interface_ids = [
azurerm_network_interface.nic.id,
]
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
sku = "2016-Datacenter"
version = "latest"
}
}