@@ -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,7 @@ 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 )
22
27
resource_group_name = azurerm_resource_group. linux_host_test . name
23
28
location = azurerm_resource_group. linux_host_test . location
24
29
size = each. value . machine_type
@@ -47,8 +52,33 @@ resource "azurerm_linux_virtual_machine" "linux_host_test" {
47
52
custom_data = filebase64 (each. value . user_data )
48
53
}
49
54
55
+ resource "azurerm_windows_virtual_machine" "linux_host_test" {
56
+ # https://azapril.dev/2020/05/12/terraform-depends_on/
57
+ depends_on = [
58
+ azurerm_network_interface_security_group_association . linux_host_test
59
+ ]
60
+ for_each = local. win_instances
61
+ name = replace (format (var. name_format , " ${ each . key } -machine" ), local. str_f , local. str_r )
62
+ resource_group_name = azurerm_resource_group. linux_host_test . name
63
+ location = azurerm_resource_group. linux_host_test . location
64
+ size = each. value . machine_type
65
+ admin_username = each. value . default_user
66
+ admin_password = each. value . default_password
67
+ network_interface_ids = [
68
+ azurerm_network_interface . linux_host_test [each . key ]. id ,
69
+ ]
50
70
71
+ os_disk {
72
+ caching = " ReadWrite"
73
+ storage_account_type = " Standard_LRS"
74
+ }
51
75
76
+ source_image_reference {
77
+ publisher = each. value . source_image_reference . publisher
78
+ offer = each. value . source_image_reference . offer
79
+ sku = each. value . source_image_reference . sku
80
+ version = each. value . source_image_reference . version
81
+ }
52
82
53
-
54
-
83
+ custom_data = filebase64 (each . value . user_data )
84
+ }
0 commit comments