Skip to content

Commit 37b2942

Browse files
committed
add: vs-code-server to Windows VM tmpl
1 parent 4b7ef3f commit 37b2942

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

templates/azure-windows-ad-auth/Initialize.ps1.tftpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,22 @@ Register-ScheduledTask @task -Force
7272
# Additional Chocolatey package installs (optional, uncomment to enable)
7373
# choco feature enable -n=allowGlobalConfirmation
7474
# choco install visualstudio2022community --package-parameters "--add=Microsoft.VisualStudio.Workload.ManagedDesktop;includeRecommended --passive --locale en-US"
75+
76+
# Download and extract Microsoft VS Code Server
77+
# Define the URL of the VS Code binary
78+
$url = "https://update.code.visualstudio.com/latest/win32-x64-archive/stable"
79+
80+
# Define the path where the binary will be downloaded
81+
$downloadPath = "$env:TEMP\VSCode.zip"
82+
83+
# Download the VS Code binary
84+
Invoke-WebRequest -Uri $url -OutFile $downloadPath
85+
86+
# Define the path where the binary will be extracted
87+
$extractPath = "C:\VSCode"
88+
89+
# Extract the VS Code binary
90+
Expand-Archive -Path $downloadPath -DestinationPath $extractPath -Force
91+
92+
# Add the directory to the system's PATH
93+
$env:Path += ";$extractPath"

templates/azure-windows-ad-auth/main.tf

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ provider "coder" {
2525
data "coder_workspace" "me" {}
2626

2727
resource "coder_agent" "main" {
28-
count = data.coder_workspace.me.transition == "start" ? 1 : 0
29-
arch = "amd64"
30-
auth = "azure-instance-identity"
31-
os = "windows"
28+
count = data.coder_workspace.me.transition == "start" ? 1 : 0
29+
arch = "amd64"
30+
auth = "azure-instance-identity"
31+
os = "windows"
32+
startup_script = <<-EOT
33+
code serve-web --without-connection-token
34+
35+
EOT
3236

3337
metadata {
3438
key = "cpu"
@@ -53,6 +57,22 @@ resource "coder_agent" "main" {
5357
}
5458
}
5559

60+
resource "coder_app" "code-server" {
61+
agent_id = coder_agent.main.id
62+
slug = "vs-code-server"
63+
display_name = "vs-code-server"
64+
url = "http://localhost:8000"
65+
icon = "/icon/code.svg"
66+
subdomain = false
67+
share = "owner"
68+
69+
healthcheck {
70+
url = "http://localhost:8000/healthz"
71+
interval = 5
72+
threshold = 6
73+
}
74+
}
75+
5676
#Generate random password for default user
5777
resource "random_password" "admin_password" {
5878
length = 16

0 commit comments

Comments
 (0)