@@ -121,6 +121,18 @@ variable "auto_install_extensions" {
121
121
default = false
122
122
}
123
123
124
+ variable "subdomain" {
125
+ type = bool
126
+ description = <<- EOT
127
+ Determines whether the app will be accessed via it's own subdomain or whether it will be accessed via a path on Coder.
128
+ If wildcards have not been setup by the administrator then apps with "subdomain" set to true will not be accessible.
129
+ EOT
130
+ default = true
131
+ }
132
+
133
+ data "coder_workspace_owner" "me" {}
134
+ data "coder_workspace" "me" {}
135
+
124
136
resource "coder_script" "vscode-web" {
125
137
agent_id = var. agent_id
126
138
display_name = " VS Code Web"
@@ -138,6 +150,7 @@ resource "coder_script" "vscode-web" {
138
150
EXTENSIONS_DIR : var.extensions_dir,
139
151
FOLDER : var.folder,
140
152
AUTO_INSTALL_EXTENSIONS : var.auto_install_extensions,
153
+ SERVER_BASE_PATH : local.server_base_path,
141
154
})
142
155
run_on_start = true
143
156
@@ -158,15 +171,21 @@ resource "coder_app" "vscode-web" {
158
171
agent_id = var. agent_id
159
172
slug = var. slug
160
173
display_name = var. display_name
161
- url = var . folder == " " ? " http://localhost: ${ var . port } " : " http://localhost: ${ var . port } ?folder= ${ var . folder } "
174
+ url = local . url
162
175
icon = " /icon/code.svg"
163
- subdomain = true
176
+ subdomain = var . subdomain
164
177
share = var. share
165
178
order = var. order
166
179
167
180
healthcheck {
168
- url = " http://localhost: ${ var . port } /healthz "
181
+ url = local . healthcheck_url
169
182
interval = 5
170
183
threshold = 6
171
184
}
172
185
}
186
+
187
+ locals {
188
+ server_base_path = var. subdomain ? " " : format (" /@%s/%s/apps/%s/" , data. coder_workspace_owner . me . name , data. coder_workspace . me . name , var. slug )
189
+ url = var. folder == " " ? " http://localhost:${ var . port } ${ local . server_base_path } " : " http://localhost:${ var . port } ${ local . server_base_path } ?folder=${ var . folder } "
190
+ healthcheck_url = var. subdomain ? " http://localhost:${ var . port } /healthz" : " http://localhost:${ var . port } ${ local . server_base_path } /healthz"
191
+ }
0 commit comments