@@ -65,6 +65,15 @@ variable "volume_size" {
6565 }
6666}
6767
68+ variable "code_server" {
69+ description = " Should Code Server be installed?"
70+ default = " true"
71+ validation {
72+ condition = contains ([" true" ," false" ], var. code_server )
73+ error_message = " Your answer can only be yes or no!"
74+ }
75+ }
76+
6877data "coder_workspace" "me" {
6978}
7079
@@ -73,17 +82,27 @@ resource "coder_agent" "dev" {
7382 os = " linux"
7483}
7584
85+ resource "coder_app" "code-server" {
86+ count = var. code_server ? 1 : 0
87+ agent_id = coder_agent. dev . id
88+ name = " code-server"
89+ icon = " https://cdn.icon-icons.com/icons2/2107/PNG/512/file_type_vscode_icon_130084.png"
90+ url = " http://localhost:8080"
91+ relative_path = true
92+ }
93+
7694resource "hcloud_server" "root" {
77- count = data. coder_workspace . me . start_count
95+ count = data. coder_workspace . me . start_count
7896 name = " coder-${ data . coder_workspace . me . owner } -${ data . coder_workspace . me . name } -root"
7997 server_type = var. instance_type
8098 location = var. instance_location
8199 image = var. instance_os
82- user_data = templatefile (" cloud-config.yaml.tftpl" , {
100+ user_data = templatefile (" cloud-config.yaml.tftpl" , {
83101 username = data.coder_workspace.me.owner
84102 volume_path = " /dev/disk/by-id/scsi-0HC_Volume_${ hcloud_volume . root . id } "
85103 init_script = base64encode (coder_agent. dev . init_script )
86104 coder_agent_token = coder_agent.dev.token
105+ code_server_setup = var.code_server
87106 })
88107}
89108
0 commit comments