Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit aa294c3

Browse files
authored
Add support for subdomain to main.tf in jupyterlab module
1 parent 8a0ac34 commit aa294c3

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

jupyterlab/main.tf

+25-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ terraform {
99
}
1010
}
1111

12+
data "coder_workspace" "me" {}
13+
data "coder_workspace_owner" "me" {}
14+
1215
# Add required variables for your modules and remove any unneeded variables
1316
variable "agent_id" {
1417
type = string
@@ -36,6 +39,15 @@ variable "share" {
3639
}
3740
}
3841

42+
variable "subdomain" {
43+
type = bool
44+
default = true
45+
validation {
46+
condition = var.share == "owner" || var.share == "authenticated" || var.share == "public"
47+
error_message = "Incorrect value. Please set either 'owner', 'authenticated', or 'public'."
48+
}
49+
}
50+
3951
variable "order" {
4052
type = number
4153
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
@@ -49,17 +61,27 @@ resource "coder_script" "jupyterlab" {
4961
script = templatefile("${path.module}/run.sh", {
5062
LOG_PATH : var.log_path,
5163
PORT : var.port
64+
BASE_URL : var.subdomain ? "http://localhost:${var.port}/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}/apps/jupyterlab" : ""
5265
})
5366
run_on_start = true
5467
}
5568

5669
resource "coder_app" "jupyterlab" {
5770
agent_id = var.agent_id
58-
slug = "jupyterlab"
71+
slug = "jupyterlab" # sync with with end of subdomain URL
5972
display_name = "JupyterLab"
60-
url = "http://localhost:${var.port}"
73+
url = var.subdomain ? "http://localhost:${var.port}/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}/apps/jupyterlab" : "http://localhost:${var.port}"
6174
icon = "/icon/jupyter.svg"
62-
subdomain = true
75+
subdomain = var.subdomain
6376
share = var.share
6477
order = var.order
78+
79+
dynamic "healthcheck" {
80+
for_each = var.subdomain ? toset([true]) : toset([])
81+
content {
82+
url = "http://localhost:${var.port}/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}/apps/jupyterlab"
83+
interval = 6
84+
threshold = 10
85+
}
86+
}
6587
}

0 commit comments

Comments
 (0)