forked from HoussemDellai/azure-monitoring-course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvm-windows.tf
More file actions
112 lines (95 loc) · 4.04 KB
/
Copy pathvm-windows.tf
File metadata and controls
112 lines (95 loc) · 4.04 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
resource "azurerm_public_ip" "pip_vm_windows" {
name = "pip-vm-windows"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
allocation_method = "Static"
sku = "Standard"
}
resource "azurerm_network_interface" "nic_vm_windows" {
name = "nic_vm_windows"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.snet_vm.id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.pip_vm_windows.id
}
}
resource "azurerm_windows_virtual_machine" "vm_windows" {
name = "vm-win11"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
size = "Standard_D4ads_v6" # "Standard_D96ads_v5" #
admin_username = "azureuser"
admin_password = "@Aa123456789"
priority = "Spot"
eviction_policy = "Delete" # "Deallocate" # With Spot, there's no option of Stop-Deallocate for Ephemeral VMs, rather users need to Delete instead of deallocating them.
network_interface_ids = [azurerm_network_interface.nic_vm_windows.id]
license_type = "Windows_Client" # Possible values are None, Windows_Client and Windows_Server.
disk_controller_type = "NVMe" # "SCSI" # "IDE" # "SCSI" is the default value. "NVMe" is only supported for Ephemeral OS Disk.
# custom_data = filebase64("../scripts/install-tools-windows.ps1")
os_disk {
name = "os-disk-vm-windows"
caching = "ReadOnly" # "ReadWrite" # None, ReadOnly and ReadWrite.
storage_account_type = "StandardSSD_LRS" # "Standard_LRS"
disk_size_gb = 128 # 128
diff_disk_settings {
option = "Local" # Specifies the Ephemeral Disk Settings for the OS Disk. At this time the only possible value is Local.
placement = "NvmeDisk" # "ResourceDisk" # "CacheDisk" # Specifies the Ephemeral Disk Placement for the OS Disk. NvmeDisk can only be used for v6 VMs
}
}
source_image_reference {
publisher = "MicrosoftWindowsDesktop"
offer = "windows-11" # "windows11preview-arm64"
sku = "win11-24h2-pro"
version = "latest"
}
identity {
type = "SystemAssigned"
}
boot_diagnostics {
storage_account_uri = null
}
lifecycle {
ignore_changes = [identity]
}
}
# resource "azurerm_managed_disk" "example" {
# name = "acctestmd"
# location = azurerm_resource_group.example.location
# resource_group_name = azurerm_resource_group.example.name
# storage_account_type = "Standard_LRS"
# create_option = "Empty"
# disk_size_gb = "1"
# }
# resource "azurerm_virtual_machine_extension" "cse" {
# name = "cse"
# virtual_machine_id = azurerm_windows_virtual_machine.vm-windows.id
# publisher = "Microsoft.Compute"
# type = "CustomScriptExtension"
# type_handler_version = "1.10"
# settings = <<SETTINGS
# {
# "commandToExecute": "powershell -ExecutionPolicy unrestricted -NoProfile -NonInteractive -command \"cp c:/azuredata/customdata.bin c:/azuredata/install.ps1; c:/azuredata/install.ps1 > c:/azuredata/install.ps1.log\""
# }
# SETTINGS
# timeouts {
# create = "60m"
# read = "5m"
# update = "30m"
# delete = "30m"
# }
# }
resource "azurerm_role_assignment" "owner" {
scope = data.azurerm_subscription.current.id
role_definition_name = "Owner"
principal_id = azurerm_windows_virtual_machine.vm_windows.identity[0].principal_id
}
data "azurerm_subscription" "current" {}
output "vm_windows_public_ip" {
value = azurerm_public_ip.pip_vm_windows.ip_address
}
output "vm_windows_private_ip" {
value = azurerm_network_interface.nic_vm_windows.private_ip_address
}