-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindows-vm-commands.tf
39 lines (32 loc) · 1.31 KB
/
windows-vm-commands.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
resource "azurerm_virtual_machine_extension" "windows_vm_inline_command" {
count = lower(var.os_type) == "windows" && try(var.script_file, null) == null && try(var.command, null) != null ? 1 : 0
name = "${var.vm_name}-run-command"
publisher = "Microsoft.CPlat.Core"
type = "RunCommandWindows"
type_handler_version = "1.1"
auto_upgrade_minor_version = true
settings = jsonencode({
script = tolist([var.command])
})
tags = var.tags
virtual_machine_id = data.azurerm_virtual_machine.azure_vm.id
lifecycle {
ignore_changes = all
}
}
resource "azurerm_virtual_machine_extension" "windows_vm_file_command" {
count = lower(var.os_type) == "windows" && try(var.script_file, null) != null && try(var.command, null) == null ? 1 : 0
name = "${var.vm_name}-run-command"
publisher = "Microsoft.CPlat.Core"
type = "RunCommandWindows"
type_handler_version = "1.1"
auto_upgrade_minor_version = true
settings = jsonencode({
script = compact(tolist([var.script_file]))
})
tags = var.tags
virtual_machine_id = data.azurerm_virtual_machine.azure_vm.id
lifecycle {
ignore_changes = all
}
}