Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows image field to Admin VM template #4274

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ENHANCEMENTS:
* Update Guacamole dependencies ([[#4232](https://github.com/microsoft/AzureTRE/issues/4232)])
* Add option to force tunnel TRE's Firewall ([#4237](https://github.com/microsoft/AzureTRE/issues/4237))
* Add EventGrid diagnostics to identify airlock issues ([#4258](https://github.com/microsoft/AzureTRE/issues/4258))
* Add Windows image field to the Admin VM template ([#4274](https://github.com/microsoft/AzureTRE/pull/4274))
* Surface the server-layout parameter of Guacamole [server-layout](https://guacamole.apache.org/doc/gug/configuring-guacamole.html#session-settings) ([#4234](https://github.com/microsoft/AzureTRE/issues/4234))

BUG FIXES:
Expand Down
12 changes: 12 additions & 0 deletions templates/shared_services/admin-vm/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@
"source": {
"env": "KEY_STORE_ID"
}
},
{
"name": "os_image",
"source": {
"env": "OS_IMAGE"
}
},
{
"name": "image_gallery_id",
"source": {
"env": "IMAGE_GALLERY_ID"
}
}
]
}
27 changes: 26 additions & 1 deletion templates/shared_services/admin-vm/porter.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
---
schemaVersion: 1.0.0
name: tre-shared-service-admin-vm
version: 0.5.1
version: 0.5.2
description: "An admin vm shared service"
dockerfile: Dockerfile.tmpl
registry: azuretre

custom:
image_options:
"Windows 11":
source_image_reference:
publisher: MicrosoftWindowsDesktop
offer: windows-11
sku: win11-24h2-pro
version: latest
# For information on using custom images, see README.me in the guacamole/user-resources folder
# "Custom Image From Gallery":
# source_image_name: your-image

credentials:
- name: azure_tenant_id
env: ARM_TENANT_ID
Expand Down Expand Up @@ -50,6 +62,13 @@ parameters:
- name: key_store_id
type: string
default: ""
- name: os_image
type: string
default: "Windows 11"
- name: image_gallery_id
type: string
description: Azure resource ID for the compute image gallery to pull images from (if specifying custom images by name)
default: ""

mixins:
- terraform:
Expand All @@ -64,6 +83,8 @@ install:
admin_jumpbox_vm_sku: ${ bundle.parameters.admin_jumpbox_vm_sku }
enable_cmk_encryption: ${ bundle.parameters.enable_cmk_encryption }
key_store_id: ${ bundle.parameters.key_store_id }
image_gallery_id: ${ bundle.parameters.image_gallery_id }
image: ${ bundle.parameters.os_image }
backendConfig:
use_azuread_auth: "true"
use_oidc: "true"
Expand All @@ -81,6 +102,8 @@ upgrade:
admin_jumpbox_vm_sku: ${ bundle.parameters.admin_jumpbox_vm_sku }
enable_cmk_encryption: ${ bundle.parameters.enable_cmk_encryption }
key_store_id: ${ bundle.parameters.key_store_id }
image_gallery_id: ${ bundle.parameters.image_gallery_id }
image: ${ bundle.parameters.os_image }
backendConfig:
use_azuread_auth: "true"
use_oidc: "true"
Expand All @@ -98,6 +121,8 @@ uninstall:
admin_jumpbox_vm_sku: ${ bundle.parameters.admin_jumpbox_vm_sku }
enable_cmk_encryption: ${ bundle.parameters.enable_cmk_encryption }
key_store_id: ${ bundle.parameters.key_store_id }
image_gallery_id: ${ bundle.parameters.image_gallery_id }
image: ${ bundle.parameters.os_image }
backendConfig:
use_azuread_auth: "true"
use_oidc: "true"
Expand Down
10 changes: 10 additions & 0 deletions templates/shared_services/admin-vm/template_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
"description": "Provides VM in the core network",
"required": [],
"properties": {
"os_image": {
"$id": "#/properties/os_image",
"type": "string",
"title": "Windows image",
"description": "Select Windows image to use for VM",
"enum": [
"Windows 11"
],
"default": "Windows 11"
},
"admin_jumpbox_vm_sku": {
"$id": "#/properties/admin_jumpbox_vm_sku",
"type": "string",
Expand Down
15 changes: 10 additions & 5 deletions templates/shared_services/admin-vm/terraform/admin-jumpbox.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ resource "azurerm_windows_virtual_machine" "jumpbox" {
admin_password = random_password.password.result
tags = local.tre_shared_service_tags

source_image_reference {
publisher = "MicrosoftWindowsDesktop"
offer = "windows-11"
sku = "win11-24h2-pro"
version = "latest"
# set source_image_id/reference depending on the config for the selected image
source_image_id = local.selected_image_source_id
dynamic "source_image_reference" {
for_each = local.selected_image_source_refs
content {
publisher = source_image_reference.value["publisher"]
offer = source_image_reference.value["offer"]
sku = source_image_reference.value["sku"]
version = source_image_reference.value["version"]
}
}

os_disk {
Expand Down
10 changes: 10 additions & 0 deletions templates/shared_services/admin-vm/terraform/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,14 @@ locals {
}
cmk_name = "tre-encryption-${var.tre_id}"
encryption_identity_name = "id-encryption-${var.tre_id}"

# Load image details from porter.yaml
porter_yaml = yamldecode(file("${path.module}/../porter.yaml"))
image_details = local.porter_yaml["custom"]["image_options"]

# Create local variables to support the VM resource
selected_image = local.image_details[var.image]
# selected_image_source_refs is an array to enable easy use of a dynamic block
selected_image_source_refs = lookup(local.selected_image, "source_image_reference", null) == null ? [] : [local.selected_image.source_image_reference]
selected_image_source_id = lookup(local.selected_image, "source_image_name", null) == null ? null : "${var.image_gallery_id}/images/${local.selected_image.source_image_name}"
}
9 changes: 9 additions & 0 deletions templates/shared_services/admin-vm/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ variable "enable_cmk_encryption" {
variable "key_store_id" {
type = string
}

variable "image_gallery_id" {
type = string
default = ""
}

variable "image" {
type = string
}
Loading