Skip to content

Commit 02db9dc

Browse files
committed
add git via user_data :(
1 parent f10a27a commit 02db9dc

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

examples/templates/aws-windows/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@ tags: [cloud, aws]
88

99
<img src="./screenshot.png" width="600" />
1010

11+
## Installing Packages
12+
13+
This template will add the [Chocolatey Package Manager](https://chocolatey.org/) via the user data. This can be used to add software to your workspace.
14+
15+
**ex. Firefox**:
16+
17+
```powershell
18+
choco install firefox
19+
```
20+
21+
**ex. Visual Studio 2019 + Managed Desktop Tools**:
22+
23+
```powershell
24+
choco install visualstudio2019community --package-parameters "--add=Microsoft.VisualStudio.Workload.ManagedDesktop;includeRecommended --passive --locale en-US"
25+
```
26+
27+
> You can pre-install packages in the `startup_script` to add them to all workspaces! `git` is added this way.
28+
29+
To remove chocolatey from this template,
30+
1131
## Connecting via RDP
1232

1333
You can connect to your workspace over a RDP tunnel. First, ensure

examples/templates/aws-windows/main.tf

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
8787
# Disable Network Level Authentication (NLA)
8888
# Clients will connect via Coder's tunnel
8989
(Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices -ComputerName $env:COMPUTERNAME -Filter "TerminalName='RDP-tcp'").SetUserAuthenticationRequired(0)
90-
91-
# Install Chocolatey package manager
92-
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
9390
EOF
9491
}
9592

@@ -104,6 +101,18 @@ locals {
104101
# https://github.com/hashicorp/terraform-provider-aws/issues/22
105102
user_data_start = <<EOT
106103
<powershell>
104+
105+
# Install Chocolatey package manager before
106+
# the agent starts to use via startup_script
107+
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
108+
109+
# Reload path so sessions include "choco" and "refreshenv"
110+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
111+
112+
# Install Git and reload path
113+
choco install -y git
114+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
115+
107116
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
108117
${coder_agent.main.init_script}
109118
</powershell>

0 commit comments

Comments
 (0)