@@ -409,13 +409,13 @@ enter the docker socket as a Terraform variable.
409
409
An example use case is the user should decide if they want a browser-based IDE
410
410
like code-server when creating the workspace.
411
411
412
- 1. Create a `coder_parameter` as a `bool` to ask the user if they want the
412
+ 1. Add a `coder_parameter` with type `bool` to ask the user if they want the
413
413
code-server IDE
414
414
415
415
` ` ` hcl
416
416
data "coder_parameter" "code_server" {
417
- name = "code-server (optional) "
418
- description = "Use VS Code in a browser"
417
+ name = "Do you want code-server in your workspace? "
418
+ description = "Use VS Code in a browser. "
419
419
type = "bool"
420
420
default = false
421
421
mutable = true
@@ -425,10 +425,10 @@ data "coder_parameter" "code_server" {
425
425
` ` `
426
426
427
427
2. Add conditional logic to the `startup_script` to install and start
428
- code-server if the `bool` is true
428
+ code-server depending on the value of the added `coder_parameter`
429
429
430
430
` ` ` sh
431
- # install and code-server, VS Code in a browser
431
+ # install and start code-server, VS Code in a browser
432
432
433
433
if [ ${data.coder_parameter.code_server.value} = true ]; then
434
434
echo "🧑🏼💻 Downloading and installing the latest code-server IDE..."
@@ -437,13 +437,15 @@ if [ ${data.coder_parameter.code_server.value} = true ]; then
437
437
fi
438
438
` ` `
439
439
440
- 3. Add a Terraform meta-argument `count` in the `coder_app` resource so it will
441
- only create the resource if the `coder_parameter` is true
440
+ 3. Add a Terraform meta-argument
441
+ [`count`](https://developer.hashicorp.com/terraform/language/meta-arguments/count)
442
+ in the `coder_app` resource so it will only create the resource if the
443
+ ` coder_parameter` is `true`
442
444
443
445
` ` ` hcl
444
446
# code-server
445
447
resource "coder_app" "code-server" {
446
- count = data.coder_parameter.code_server.value ? 1 : 0
448
+ count = data.coder_parameter.code_server.value ? 1 : 0
447
449
agent_id = coder_agent.coder.id
448
450
slug = "code-server"
449
451
display_name = "code-server"
0 commit comments