Skip to content

Commit dfc8cdc

Browse files
committed
Enable scheduled shutdown of Guacamole Windows VMs
Fixes #4205 Add support for scheduled shutdown of Guacamole Windows VMs. * Add `enable_shutdown_schedule`, `shutdown_time`, and `shutdown_timezone` properties to `template_schema.json`. * Add `enable_shutdown_schedule`, `shutdown_time`, and `shutdown_timezone` parameters to `porter.yaml`. * Add `azurerm_dev_test_global_vm_shutdown_schedule` resource to `windowsvm.tf`. * Add `enable_shutdown_schedule`, `shutdown_time`, and `shutdown_timezone` variables to `variables.tf`. * Update bundle version in `porter.yaml`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/microsoft/AzureTRE/issues/4205?shareId=XXXX-XXXX-XXXX-XXXX).
1 parent 04df2b8 commit dfc8cdc

File tree

4 files changed

+117
-2
lines changed

4 files changed

+117
-2
lines changed

templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/porter.yaml

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
schemaVersion: 1.0.0
33
name: tre-service-guacamole-windowsvm
4-
version: 1.0.7
4+
version: 1.0.8
55
description: "An Azure TRE User Resource Template for Guacamole (Windows 10)"
66
dockerfile: Dockerfile.tmpl
77
registry: azuretre
@@ -100,6 +100,19 @@ parameters:
100100
default: "vm-shared-storage"
101101
- name: arm_environment
102102
type: string
103+
- name: enable_shutdown_schedule
104+
type: boolean
105+
default: false
106+
description: "Enable automatic shutdown schedule for the VM"
107+
- name: shutdown_time
108+
default: ""
109+
type: string
110+
description: "Time of day to shutdown the VM (HHmm format)"
111+
pattern: "^([01]?[0-9]|2[0-3])[0-5][0-9]$"
112+
- name: shutdown_timezone
113+
type: string
114+
description: "Timezone for the shutdown schedule"
115+
default: "UTC"
103116

104117
outputs:
105118
- name: ip
@@ -145,6 +158,9 @@ install:
145158
shared_storage_access: ${ bundle.parameters.shared_storage_access }
146159
shared_storage_name: ${ bundle.parameters.shared_storage_name }
147160
image_gallery_id: ${ bundle.parameters.image_gallery_id }
161+
enable_shutdown_schedule: ${ bundle.parameters.enable_shutdown_schedule }
162+
shutdown_time: ${ bundle.parameters.shutdown_time }
163+
shutdown_timezone: ${ bundle.parameters.shutdown_timezone }
148164
backendConfig:
149165
use_azuread_auth: "true"
150166
use_oidc: "true"
@@ -171,6 +187,9 @@ upgrade:
171187
shared_storage_access: ${ bundle.parameters.shared_storage_access }
172188
shared_storage_name: ${ bundle.parameters.shared_storage_name }
173189
image_gallery_id: ${ bundle.parameters.image_gallery_id }
190+
enable_shutdown_schedule: ${ bundle.parameters.enable_shutdown_schedule }
191+
shutdown_time: ${ bundle.parameters.shutdown_time }
192+
shutdown_timezone: ${ bundle.parameters.shutdown_timezone }
174193
backendConfig:
175194
use_azuread_auth: "true"
176195
use_oidc: "true"
@@ -209,6 +228,9 @@ uninstall:
209228
shared_storage_access: ${ bundle.parameters.shared_storage_access }
210229
shared_storage_name: ${ bundle.parameters.shared_storage_name }
211230
image_gallery_id: ${ bundle.parameters.image_gallery_id }
231+
enable_shutdown_schedule: ${ bundle.parameters.enable_shutdown_schedule }
232+
shutdown_time: ${ bundle.parameters.shutdown_time }
233+
shutdown_timezone: ${ bundle.parameters.shutdown_timezone }
212234
backendConfig:
213235
use_azuread_auth: "true"
214236
use_oidc: "true"

templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/template_schema.json

+70-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,75 @@
4040
"title": "Shared storage",
4141
"default": true,
4242
"description": "Enable access to shared storage"
43+
},
44+
"enable_shutdown_schedule": {
45+
"$id": "#/properties/enable_shutdown_schedule",
46+
"type": "boolean",
47+
"title": "Enable Shutdown Schedule",
48+
"default": false,
49+
"description": "Enable automatic shutdown schedule for the VM"
50+
}
51+
},
52+
"allOf": [
53+
{
54+
"if": {
55+
"properties": {
56+
"enable_shutdown_schedule": {
57+
"const": true
58+
}
59+
},
60+
"required": [
61+
"enable_shutdown_schedule"
62+
]
63+
},
64+
"then": {
65+
"properties": {
66+
"shutdown_time": {
67+
"type": "string",
68+
"title": "Shutdown Time",
69+
"description": "Time of day to shutdown the VM (HHmm format), e.g. 1800",
70+
"pattern": "^([01]?[0-9]|2[0-3])[0-5][0-9]$",
71+
"default": "1800"
72+
},
73+
"shutdown_timezone": {
74+
"type": "string",
75+
"title": "Shutdown Timezone",
76+
"description": "Timezone for the shutdown schedule",
77+
"default": "UTC",
78+
"enum": [
79+
"UTC -12",
80+
"UTC -11",
81+
"UTC -10",
82+
"UTC -9",
83+
"UTC -8",
84+
"UTC -7",
85+
"UTC -6",
86+
"UTC -5",
87+
"UTC -4",
88+
"UTC -3",
89+
"UTC -2",
90+
"UTC -1",
91+
"UTC",
92+
"UTC +1",
93+
"UTC +2",
94+
"UTC +3",
95+
"UTC +4",
96+
"UTC +5",
97+
"UTC +6",
98+
"UTC +7",
99+
"UTC +8",
100+
"UTC +9",
101+
"UTC +10",
102+
"UTC +11",
103+
"UTC +12"
104+
]
105+
}
106+
},
107+
"required": [
108+
"shutdown_time",
109+
"shutdown_timezone"
110+
]
111+
}
43112
}
44-
}
113+
]
45114
}

templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/terraform/variables.tf

+11
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,14 @@ variable "image_gallery_id" {
2626
type = string
2727
default = ""
2828
}
29+
variable "enable_shutdown_schedule" {
30+
type = bool
31+
default = false
32+
}
33+
variable "shutdown_time" {
34+
type = string
35+
}
36+
variable "shutdown_timezone" {
37+
type = string
38+
default = "UTC"
39+
}

templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/terraform/windowsvm.tf

+13
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,16 @@ resource "azurerm_key_vault_secret" "windowsvm_password" {
110110

111111
lifecycle { ignore_changes = [tags] }
112112
}
113+
114+
resource "azurerm_dev_test_global_vm_shutdown_schedule" "shutdown_schedule" {
115+
count = var.enable_shutdown_schedule ? 1 : 0
116+
117+
location = data.azurerm_resource_group.ws.location
118+
virtual_machine_id = azurerm_windows_virtual_machine.windowsvm.id
119+
daily_recurrence_time = var.shutdown_time
120+
timezone = var.shutdown_timezone
121+
enabled = var.enable_shutdown_schedule
122+
notification_settings {
123+
enabled = false
124+
}
125+
}

0 commit comments

Comments
 (0)