-
Notifications
You must be signed in to change notification settings - Fork 0
/
vm.extensions.tf
68 lines (58 loc) · 2.17 KB
/
vm.extensions.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
58
59
60
61
62
63
64
65
66
67
68
#
# Custom Script Extension
#
# Linux
resource "azurerm_virtual_machine_extension" "vm_linux" {
count = var.custom_script_extension.enabled && local.is_linux ? var.instances : 0
name = var.custom_script_extension.name
virtual_machine_id = azurerm_linux_virtual_machine.vm[count.index].id
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.0"
settings = <<SETTINGS
{
"script": "${var.custom_script_extension.script}"
}
SETTINGS
}
# Windows
resource "azurerm_virtual_machine_extension" "vm_windows" {
count = var.custom_script_extension.enabled && local.is_linux != true ? var.instances : 0
name = var.custom_script_extension.name
virtual_machine_id = azurerm_windows_virtual_machine.vm[count.index].id
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.10"
protected_settings = <<SETTINGS
{
"commandToExecute": "powershell -ExecutionPolicy Unrestricted -encodedCommand ${var.custom_script_extension.script}"
}
SETTINGS
}
# Azure Virtual Desktop
# Despite the other VM extension taking care of the Azure AD Join, we have to specify the property here too.
resource "azurerm_virtual_machine_extension" "avd" {
count = var.avd_extension.enabled && local.is_linux != true ? var.instances : 0
name = "AzureVirtualDesktopSessionHost"
virtual_machine_id = azurerm_windows_virtual_machine.vm[count.index].id
publisher = "Microsoft.Powershell"
type = "DSC"
type_handler_version = "2.73"
settings = <<-SETTINGS
{
"modulesUrl": "${var.config.compute.virtualMachines.azure_virtual_desktop.config.agentUrl}",
"configurationFunction": "Configuration.ps1\\AddSessionHost",
"properties": {
"HostPoolName":"${var.avd_extension.hostPoolName}",
"aadJoin": ${var.avd_extension.aadJoin}
}
}
SETTINGS
protected_settings = <<PROTECTED_SETTINGS
{
"properties": {
"registrationInfoToken": "${var.avd_extension.registrationInfoToken}"
}
}
PROTECTED_SETTINGS
}