Skip to content

Commit

Permalink
Enable scheduled shutdown of Guacamole Linux VM (#4196)
Browse files Browse the repository at this point in the history
* Enable scheduled shutdown of Guacamole VMs

* Enable Scheduled Shutdown of Guacamole VMs
Fixes #4186

* Fix defaults.

* Update templates/workspace_services/guacamole/user_resources/guacamole-azure-linuxvm/porter.yaml

Co-authored-by: Tamir Kamara <26870601+tamirkamara@users.noreply.github.com>

---------

Co-authored-by: Tamir Kamara <26870601+tamirkamara@users.noreply.github.com>
Co-authored-by: Tim Allen <tim.allen@cloudkubed.com>
  • Loading branch information
3 people authored Dec 18, 2024
1 parent 5e857f6 commit a7c9a28
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ENHANCEMENTS:
* Move Github PR bot commands into main documentation ([#4167](https://github.com/microsoft/AzureTRE/pull/4167))
* Block Authentication with keys to CosmosDB SQL account ([#4175](https://github.com/microsoft/AzureTRE/pull/4175))
* Add support for customer-managed keys encryption in base workspace ([#4161](https://github.com/microsoft/AzureTRE/pull/4161))
* Add option to configure auto shutdown for Linux VM ([#4186](https://github.com/microsoft/AzureTRE/issues/4186))
* Add ability to download VSCode Extensions ([[#4187](https://github.com/microsoft/AzureTRE/issues/4187)])
* Update Windows VM Images ([#4198](https://github.com/microsoft/AzureTRE/pull/4198))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
schemaVersion: 1.0.0
name: tre-service-guacamole-linuxvm
version: 1.0.8
version: 1.1.0
description: "An Azure TRE User Resource Template for Guacamole (Linux)"
dockerfile: Dockerfile.tmpl
registry: azuretre
Expand Down Expand Up @@ -56,6 +56,19 @@ parameters:
type: string
description: Azure resource ID for the compute image gallery to pull images from (if specifying custom images by name)
default: ""
- name: enable_shutdown_schedule
type: boolean
default: false
description: "Enable automatic shutdown schedule for the VM"
- name: shutdown_time
default: ""
type: string
description: "Time of day to shutdown the VM (HHmm format)"
pattern: "^([01]?[0-9]|2[0-3])[0-5][0-9]$"
- name: shutdown_timezone
type: string
description: "Timezone for the shutdown schedule"
default: "UTC"

# the following are added automatically by the resource processor
- name: id
Expand Down Expand Up @@ -138,6 +151,9 @@ install:
shared_storage_access: ${ bundle.parameters.shared_storage_access }
shared_storage_name: ${ bundle.parameters.shared_storage_name }
image_gallery_id: ${ bundle.parameters.image_gallery_id }
enable_shutdown_schedule: ${ bundle.parameters.enable_shutdown_schedule }
shutdown_time: ${ bundle.parameters.shutdown_time }
shutdown_timezone: ${ bundle.parameters.shutdown_timezone }
backendConfig:
use_azuread_auth: "true"
use_oidc: "true"
Expand All @@ -164,6 +180,9 @@ upgrade:
shared_storage_access: ${ bundle.parameters.shared_storage_access }
shared_storage_name: ${ bundle.parameters.shared_storage_name }
image_gallery_id: ${ bundle.parameters.image_gallery_id }
enable_shutdown_schedule: ${ bundle.parameters.enable_shutdown_schedule }
shutdown_time: ${ bundle.parameters.shutdown_time }
shutdown_timezone: ${ bundle.parameters.shutdown_timezone }
backendConfig:
use_azuread_auth: "true"
use_oidc: "true"
Expand Down Expand Up @@ -202,6 +221,9 @@ uninstall:
shared_storage_access: ${ bundle.parameters.shared_storage_access }
shared_storage_name: ${ bundle.parameters.shared_storage_name }
image_gallery_id: ${ bundle.parameters.image_gallery_id }
enable_shutdown_schedule: ${ bundle.parameters.enable_shutdown_schedule }
shutdown_time: ${ bundle.parameters.shutdown_time }
shutdown_timezone: ${ bundle.parameters.shutdown_timezone }
backendConfig:
use_azuread_auth: "true"
use_oidc: "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"title": "Linux Virtual Machine",
"description": "Linux virtual machine.",
"required": [
"os_image",
"vm_size"
],
"authorizedRoles": [
"WorkspaceOwner", "WorkspaceResearcher"
Expand All @@ -15,6 +17,7 @@
"type": "string",
"title": "Linux image",
"description": "Select Linux image to use for VM",
"default": "Ubuntu 22.04 LTS",
"enum": [
"Ubuntu 22.04 LTS"
]
Expand All @@ -24,6 +27,7 @@
"type": "string",
"title": "VM Size",
"description": "Select size of VM",
"default": "2 CPU | 8GB RAM",
"enum": [
"2 CPU | 8GB RAM",
"4 CPU | 16GB RAM",
Expand All @@ -38,6 +42,75 @@
"title": "Shared storage",
"default": true,
"description": "Enable access to shared storage"
},
"enable_shutdown_schedule": {
"$id": "#/properties/enable_shutdown_schedule",
"type": "boolean",
"title": "Enable Shutdown Schedule",
"default": false,
"description": "Enable automatic shutdown schedule for the VM"
}
},
"allOf": [
{
"if": {
"properties": {
"enable_shutdown_schedule": {
"const": true
}
},
"required": [
"enable_shutdown_schedule"
]
},
"then": {
"properties": {
"shutdown_time": {
"type": "string",
"title": "Shutdown Time",
"description": "Time of day to shutdown the VM (HHmm format), e.g. 1800",
"pattern": "^([01]?[0-9]|2[0-3])[0-5][0-9]$",
"default": "1800"
},
"shutdown_timezone": {
"type": "string",
"title": "Shutdown Timezone",
"description": "Timezone for the shutdown schedule",
"default": "UTC",
"enum": [
"UTC -12",
"UTC -11",
"UTC -10",
"UTC -9",
"UTC -8",
"UTC -7",
"UTC -6",
"UTC -5",
"UTC -4",
"UTC -3",
"UTC -2",
"UTC -1",
"UTC",
"UTC +1",
"UTC +2",
"UTC +3",
"UTC +4",
"UTC +5",
"UTC +6",
"UTC +7",
"UTC +8",
"UTC +9",
"UTC +10",
"UTC +11",
"UTC +12"
]
}
},
"required": [
"shutdown_time",
"shutdown_timezone"
]
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,16 @@ data "azurerm_storage_share" "shared_storage" {
name = var.shared_storage_name
storage_account_name = data.azurerm_storage_account.stg.name
}

resource "azurerm_dev_test_global_vm_shutdown_schedule" "shutdown_schedule" {
count = var.enable_shutdown_schedule ? 1 : 0

location = data.azurerm_resource_group.ws.location
virtual_machine_id = azurerm_linux_virtual_machine.linuxvm.id
daily_recurrence_time = var.shutdown_time
timezone = var.shutdown_timezone
enabled = var.enable_shutdown_schedule
notification_settings {
enabled = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@ variable "image_gallery_id" {
type = string
default = ""
}
variable "enable_shutdown_schedule" {
type = bool
default = false
}
variable "shutdown_time" {
type = string
}
variable "shutdown_timezone" {
type = string
default = "UTC"
}

0 comments on commit a7c9a28

Please sign in to comment.