Skip to content

Commit e82a9df

Browse files
chapterjasonclaude
andcommitted
Plumb cwd through the web-shell terraform module
Add a `cwd` input to terraform/web-shell/ that propagates to run.sh as WEB_SHELL_CWD so web-shell sessions open in the working directory Coder already collects via coder_parameter.directory, and wire the module into the root workspace template alongside code-server / jetbrains. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0367f30 commit e82a9df

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ module "code-server" {
206206
order = 1
207207
}
208208

209+
module "web-shell" {
210+
count = data.coder_workspace.me.start_count
211+
source = "github.com/SoureCode/devcontainer-features//terraform/web-shell"
212+
agent_id = coder_devcontainer.repo[0].subagent_id
213+
cwd = data.coder_parameter.directory.value
214+
order = 2
215+
}
216+
209217
# See https://registry.coder.com/modules/coder/jetbrains
210218
module "jetbrains" {
211219
count = data.coder_workspace.me.start_count

terraform/web-shell/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ variable "install_version" {
3939
default = ""
4040
}
4141

42+
variable "cwd" {
43+
type = string
44+
description = "Working directory for new web-shell sessions (sets $WEB_SHELL_CWD). Empty uses web-shell's default."
45+
default = ""
46+
}
47+
4248
variable "log_path" {
4349
type = string
4450
description = "The path to log web-shell to."
@@ -110,6 +116,7 @@ resource "coder_script" "web-shell" {
110116
HOST : var.host,
111117
PORT : var.port,
112118
AUTH_TOKEN : var.auth_token,
119+
CWD : var.cwd,
113120
LOG_PATH : var.log_path,
114121
})
115122
run_on_start = true

terraform/web-shell/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RESET='\033[0m'
66
function run_web_shell() {
77
echo "👷 Running web-shell in the background..."
88
echo "Check logs at ${LOG_PATH}!"
9-
HOST="${HOST}" PORT="${PORT}" AUTH_TOKEN="${AUTH_TOKEN}" \
9+
HOST="${HOST}" PORT="${PORT}" AUTH_TOKEN="${AUTH_TOKEN}" WEB_SHELL_CWD="${CWD}" \
1010
web-shell > "${LOG_PATH}" 2>&1 &
1111
}
1212

0 commit comments

Comments
 (0)