-
Notifications
You must be signed in to change notification settings - Fork 0
/
WindowsVM.tf
57 lines (47 loc) · 1.85 KB
/
WindowsVM.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
resource "azurerm_public_ip" "winPublicIP" {
name = "${var.suffix}${var.winVMName}"
location = azurerm_resource_group.mainRG.location
resource_group_name = azurerm_resource_group.mainRG.name
allocation_method = var.publicIPAllocation
tags = var.tags
}
resource "azurerm_network_interface" "winNI" {
name = "${var.suffix}${var.winVMName}"
location = azurerm_resource_group.mainRG.location
resource_group_name = azurerm_resource_group.mainRG.name
ip_configuration {
name = "windowsconfiguration"
subnet_id = azurerm_subnet.dynamicSubnets["main"].id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.winPublicIP.id
}
tags = var.tags
}
resource "azurerm_network_interface_security_group_association" "winSG" {
network_interface_id = azurerm_network_interface.winNI.id
network_security_group_id = azurerm_network_security_group.rdpNSG.id
}
resource "azurerm_windows_virtual_machine" "winVM" {
name = "${var.suffix}${var.winVMName}"
resource_group_name = azurerm_resource_group.mainRG.name
location = azurerm_resource_group.mainRG.location
size = var.vmSize
admin_username = var.vmUserName
admin_password = var.password
network_interface_ids = [azurerm_network_interface.winNI.id, ]
os_disk {
name = "${var.suffix}${var.winVMName}OSDisk"
caching = "ReadWrite"
storage_account_type = var.osDisk
}
source_image_reference {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
sku = var.windowsSKU
version = "latest"
}
boot_diagnostics {
storage_account_uri = azurerm_storage_account.mainSA.primary_blob_endpoint
}
tags = var.tags
}