@@ -5,6 +5,11 @@ locals {
5
5
compute_instances = { for key , value in var . AZURE_MACHINE_CONFIGS :
6
6
key => value if contains (var. AZURE_COMPUTE_FILTER , key) || length (var. AZURE_COMPUTE_FILTER ) == 0 }
7
7
8
+ win_instances = { for key , value in var . AZURE_WIN_MACHINE_CONFIGS :
9
+ key => value if contains (var. AZURE_COMPUTE_FILTER , key) || length (var. AZURE_COMPUTE_FILTER ) == 0 }
10
+
11
+ combined_instances = merge (local. compute_instances , local. win_instances )
12
+
8
13
}
9
14
10
15
resource "azurerm_resource_group" "linux_host_test" {
@@ -18,7 +23,8 @@ resource "azurerm_linux_virtual_machine" "linux_host_test" {
18
23
azurerm_network_interface_security_group_association . linux_host_test
19
24
]
20
25
for_each = local. compute_instances
21
- name = replace (format (var. name_format , " ${ each . key } -machine" ), local. str_f , local. str_r )
26
+ name = replace (format (var. name_format , " ${ each . key } -vm" ), local. str_f , local. str_r )
27
+ computer_name = each. key
22
28
resource_group_name = azurerm_resource_group. linux_host_test . name
23
29
location = azurerm_resource_group. linux_host_test . location
24
30
size = each. value . machine_type
@@ -47,8 +53,33 @@ resource "azurerm_linux_virtual_machine" "linux_host_test" {
47
53
custom_data = filebase64 (each. value . user_data )
48
54
}
49
55
56
+ resource "azurerm_windows_virtual_machine" "linux_host_test" {
57
+ # https://azapril.dev/2020/05/12/terraform-depends_on/
58
+ depends_on = [
59
+ azurerm_network_interface_security_group_association . linux_host_test
60
+ ]
61
+ for_each = local. win_instances
62
+ name = replace (format (var. name_format , " ${ each . key } -machine" ), local. str_f , local. str_r )
63
+ resource_group_name = azurerm_resource_group. linux_host_test . name
64
+ location = azurerm_resource_group. linux_host_test . location
65
+ size = each. value . machine_type
66
+ admin_username = each. value . default_user
67
+ admin_password = each. value . default_password
68
+ network_interface_ids = [
69
+ azurerm_network_interface . linux_host_test [each . key ]. id ,
70
+ ]
50
71
72
+ os_disk {
73
+ caching = " ReadWrite"
74
+ storage_account_type = " Standard_LRS"
75
+ }
51
76
77
+ source_image_reference {
78
+ publisher = each. value . source_image_reference . publisher
79
+ offer = each. value . source_image_reference . offer
80
+ sku = each. value . source_image_reference . sku
81
+ version = each. value . source_image_reference . version
82
+ }
52
83
53
-
54
-
84
+ custom_data = filebase64 (each . value . user_data )
85
+ }
0 commit comments