@@ -9,64 +9,37 @@ terraform {
9
9
}
10
10
}
11
11
12
- provider "coder" {
13
- }
12
+ provider "coder" {}
14
13
15
14
variable "project_id" {
16
15
description = " Which Google Compute Project should your workspace live in?"
17
16
}
18
17
19
- data "coder_parameter" "zone" {
20
- name = " zone"
21
- display_name = " Zone"
22
- description = " Which zone should your workspace live in?"
23
- type = " string"
24
- icon = " /emojis/1f30e.png"
25
- default = " us-central1-a"
26
- mutable = false
27
- option {
28
- name = " North America (Northeast)"
29
- value = " northamerica-northeast1-a"
30
- icon = " /emojis/1f1fa-1f1f8.png"
31
- }
32
- option {
33
- name = " North America (Central)"
34
- value = " us-central1-a"
35
- icon = " /emojis/1f1fa-1f1f8.png"
36
- }
37
- option {
38
- name = " North America (West)"
39
- value = " us-west2-c"
40
- icon = " /emojis/1f1fa-1f1f8.png"
41
- }
42
- option {
43
- name = " Europe (West)"
44
- value = " europe-west4-b"
45
- icon = " /emojis/1f1ea-1f1fa.png"
46
- }
47
- option {
48
- name = " South America (East)"
49
- value = " southamerica-east1-a"
50
- icon = " /emojis/1f1e7-1f1f7.png"
51
- }
18
+ # See https://registry.coder.com/modules/gcp-region
19
+ module "gcp_region" {
20
+ source = " registry.coder.com/modules/gcp-region/coder"
21
+
22
+ # This ensures that the latest version of the module gets downloaded, you can also pin the module version to prevent breaking changes in production.
23
+ version = " >= 1.0.0"
24
+
25
+ regions = [" us" , " europe" ]
26
+ default = " us-central1-a"
52
27
}
53
28
54
29
provider "google" {
55
- zone = data . coder_parameter . zone . value
30
+ zone = module . gcp_region . value
56
31
project = var. project_id
57
32
}
58
33
59
- data "google_compute_default_service_account" "default" {
60
- }
34
+ data "google_compute_default_service_account" "default" {}
61
35
62
- data "coder_workspace" "me" {
63
- }
36
+ data "coder_workspace" "me" {}
64
37
data "coder_workspace_owner" "me" {}
65
38
66
39
resource "google_compute_disk" "root" {
67
40
name = " coder-${ data . coder_workspace . me . id } -root"
68
41
type = " pd-ssd"
69
- zone = data . coder_parameter . zone . value
42
+ zone = module . gcp_region . value
70
43
image = " debian-cloud/debian-11"
71
44
lifecycle {
72
45
ignore_changes = [name , image ]
@@ -80,12 +53,7 @@ resource "coder_agent" "main" {
80
53
startup_script = <<- EOT
81
54
set -e
82
55
83
- # Install the latest code-server.
84
- # Append "--version x.x.x" to install a specific version of code-server.
85
- curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server
86
-
87
- # Start code-server in the background.
88
- /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
56
+ # Add any commands that should be executed at workspace startup (e.g install requirements, start a program, etc) here
89
57
EOT
90
58
91
59
metadata {
@@ -123,25 +91,40 @@ resource "coder_agent" "main" {
123
91
}
124
92
}
125
93
126
- # code-server
127
- resource "coder_app" "code-server" {
128
- agent_id = coder_agent. main . id
129
- slug = " code-server"
130
- display_name = " code-server"
131
- icon = " /icon/code.svg"
132
- url = " http://localhost:13337?folder=/home/coder"
133
- subdomain = false
134
- share = " owner"
135
-
136
- healthcheck {
137
- url = " http://localhost:13337/healthz"
138
- interval = 3
139
- threshold = 10
140
- }
94
+ # See https://registry.coder.com/modules/code-server
95
+ module "code-server" {
96
+ count = data. coder_workspace . me . start_count
97
+ source = " registry.coder.com/modules/code-server/coder"
98
+
99
+ # This ensures that the latest version of the module gets downloaded, you can also pin the module version to prevent breaking changes in production.
100
+ version = " >= 1.0.0"
101
+
102
+ agent_id = coder_agent. main . id
103
+ order = 1
104
+ }
105
+
106
+ # See https://registry.coder.com/modules/jetbrains-gateway
107
+ module "jetbrains_gateway" {
108
+ count = data. coder_workspace . me . start_count
109
+ source = " registry.coder.com/modules/jetbrains-gateway/coder"
110
+
111
+ # JetBrains IDEs to make available for the user to select
112
+ jetbrains_ides = [" IU" , " PY" , " WS" , " PS" , " RD" , " CL" , " GO" , " RM" ]
113
+ default = " IU"
114
+
115
+ # Default folder to open when starting a JetBrains IDE
116
+ folder = " /home/coder"
117
+
118
+ # This ensures that the latest version of the module gets downloaded, you can also pin the module version to prevent breaking changes in production.
119
+ version = " >= 1.0.0"
120
+
121
+ agent_id = coder_agent. main . id
122
+ agent_name = " main"
123
+ order = 2
141
124
}
142
125
143
126
resource "google_compute_instance" "dev" {
144
- zone = data . coder_parameter . zone . value
127
+ zone = module . gcp_region . value
145
128
count = data. coder_workspace . me . start_count
146
129
name = " coder-${ lower (data. coder_workspace_owner . me . name )} -${ lower (data. coder_workspace . me . name )} -root"
147
130
machine_type = " e2-medium"
0 commit comments