Skip to content

Commit

Permalink
Use host in windows mount script (#3519)
Browse files Browse the repository at this point in the history
* use host in windows mount script

* Update templates/workspace_services/guacamole/user_resources/guacamole-azure-windowsvm/porter.yaml
  • Loading branch information
tamirkamara authored May 28, 2023
1 parent 6eb8288 commit 8fc8d77
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
schemaVersion: 1.0.0
name: tre-service-guacamole-windowsvm
version: 0.7.4
version: 0.7.5
description: "An Azure TRE User Resource Template for Guacamole (Windows 10)"
dockerfile: Dockerfile.tmpl
registry: azuretre
Expand Down Expand Up @@ -125,7 +125,7 @@ outputs:
mixins:
- exec
- terraform:
clientVersion: 1.3.6
clientVersion: 1.4.6
- az:
clientVersion: 2.37.0

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,14 @@ data "azurerm_public_ip" "app_gateway_ip" {
name = "pip-agw-${var.tre_id}"
resource_group_name = data.azurerm_resource_group.core.name
}

data "azurerm_storage_account" "stg" {
name = local.storage_name
resource_group_name = data.azurerm_resource_group.ws.name
}

data "azurerm_storage_share" "shared_storage" {
count = var.shared_storage_access ? 1 : 0
name = var.shared_storage_name
storage_account_name = data.azurerm_storage_account.stg.name
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=3.41.0"
version = "=3.57.0"
}
random = {
source = "hashicorp/random"
version = "=3.4.3"
}
template = {
source = "hashicorp/template"
version = "=2.2.0"
version = "=3.5.1"
}
}
backend "azurerm" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Remove-Item -LiteralPath "C:\AzureData" -Force -Recurse
$ErrorActionPreference = "Stop"

if( ${SharedStorageAccess} -eq 1 )
{
$Command = "net use z: \\${StorageAccountFileEndpoint}\${FileShareName} /u:AZURE\${StorageAccountName} ${StorageAccountKey}"
$Command | Out-File "C:\ProgramData\Start Menu\Programs\StartUp\attatch_storage.cmd" -encoding ascii
Remove-Item -LiteralPath "C:\AzureData" -Force -Recurse
$Command = "net use z: \\${StorageAccountFileHost}\${FileShareName} /u:AZURE\${StorageAccountName} ${StorageAccountKey}"
$Command | Out-File "C:\ProgramData\Start Menu\Programs\StartUp\attach_storage.cmd" -encoding ascii
}

$PipConfigFolderPath = "C:\ProgramData\pip\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,17 @@ resource "azurerm_windows_virtual_machine" "windowsvm" {
admin_username = random_string.username.result
admin_password = random_password.password.result

custom_data = base64encode(data.template_file.vm_config.rendered)
custom_data = base64encode(templatefile(
"${path.module}/vm_config.ps1", {
nexus_proxy_url = local.nexus_proxy_url
SharedStorageAccess = var.shared_storage_access ? 1 : 0
StorageAccountName = data.azurerm_storage_account.stg.name
StorageAccountKey = data.azurerm_storage_account.stg.primary_access_key
StorageAccountFileHost = data.azurerm_storage_account.stg.primary_file_host
FileShareName = var.shared_storage_access ? data.azurerm_storage_share.shared_storage[0].name : ""
CondaConfig = local.selected_image.conda_config ? 1 : 0
}
))

# set source_image_id/reference depending on the config for the selected image
source_image_id = local.selected_image_source_id
Expand Down Expand Up @@ -92,27 +102,3 @@ resource "azurerm_key_vault_secret" "windowsvm_password" {
key_vault_id = data.azurerm_key_vault.ws.id
tags = local.tre_user_resources_tags
}

data "template_file" "vm_config" {
template = file("${path.module}/vm_config.ps1")
vars = {
nexus_proxy_url = local.nexus_proxy_url
SharedStorageAccess = var.shared_storage_access ? 1 : 0
StorageAccountName = data.azurerm_storage_account.stg.name
StorageAccountKey = data.azurerm_storage_account.stg.primary_access_key
StorageAccountFileEndpoint = data.azurerm_storage_account.stg.primary_file_endpoint
FileShareName = var.shared_storage_access ? data.azurerm_storage_share.shared_storage[0].name : ""
CondaConfig = local.selected_image.conda_config ? 1 : 0
}
}

data "azurerm_storage_account" "stg" {
name = local.storage_name
resource_group_name = data.azurerm_resource_group.ws.name
}

data "azurerm_storage_share" "shared_storage" {
count = var.shared_storage_access ? 1 : 0
name = var.shared_storage_name
storage_account_name = data.azurerm_storage_account.stg.name
}

0 comments on commit 8fc8d77

Please sign in to comment.