@@ -9,58 +9,26 @@ 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
- default = " us-central1-a"
25
- icon = " /emojis/1f30e.png"
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
+ module "gcp_region" {
19
+ source = " registry.coder.com/modules/gcp-region/coder"
20
+ version = " 1.0.12"
21
+ regions = [" us" , " europe" ]
52
22
}
53
23
54
24
provider "google" {
55
- zone = data . coder_parameter . zone . value
25
+ zone = module . gcp_region . value
56
26
project = var. project_id
57
27
}
58
28
59
- data "google_compute_default_service_account" "default" {
60
- }
29
+ data "google_compute_default_service_account" "default" {}
61
30
62
- data "coder_workspace" "me" {
63
- }
31
+ data "coder_workspace" "me" {}
64
32
data "coder_workspace_owner" "me" {}
65
33
66
34
resource "coder_agent" "main" {
@@ -70,32 +38,43 @@ resource "coder_agent" "main" {
70
38
startup_script = <<- EOT
71
39
set -e
72
40
73
- # Install the latest code-server.
74
- # Append "--version x.x.x" to install a specific version of code-server.
75
- curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server
76
-
77
- # Start code-server in the background.
78
- /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
41
+ # Add any commands that should be executed at workspace startup (e.g install requirements, start a program, etc) here
79
42
EOT
80
43
}
81
44
82
- # code-server
83
- resource "coder_app" "code-server" {
84
- agent_id = coder_agent. main . id
85
- slug = " code-server"
86
- display_name = " code-server"
87
- icon = " /icon/code.svg"
88
- url = " http://localhost:13337?folder=/home/coder"
89
- subdomain = false
90
- share = " owner"
91
-
92
- healthcheck {
93
- url = " http://localhost:13337/healthz"
94
- interval = 3
95
- threshold = 10
96
- }
45
+ # See https://registry.coder.com/modules/code-server
46
+ module "code-server" {
47
+ count = data. coder_workspace . me . start_count
48
+ source = " registry.coder.com/modules/code-server/coder"
49
+
50
+ # This ensures that the latest version of the module gets downloaded, you can also pin the module version to prevent breaking changes in production.
51
+ version = " >= 1.0.0"
52
+
53
+ agent_id = coder_agent. main . id
54
+ order = 1
55
+ }
56
+
57
+ # See https://registry.coder.com/modules/jetbrains-gateway
58
+ module "jetbrains_gateway" {
59
+ count = data. coder_workspace . me . start_count
60
+ source = " registry.coder.com/modules/jetbrains-gateway/coder"
61
+
62
+ # JetBrains IDEs to make available for the user to select
63
+ jetbrains_ides = [" IU" , " PY" , " WS" , " PS" , " RD" , " CL" , " GO" , " RM" ]
64
+ default = " IU"
65
+
66
+ # Default folder to open when starting a JetBrains IDE
67
+ folder = " /home/coder"
68
+
69
+ # This ensures that the latest version of the module gets downloaded, you can also pin the module version to prevent breaking changes in production.
70
+ version = " >= 1.0.0"
71
+
72
+ agent_id = coder_agent. main . id
73
+ agent_name = " main"
74
+ order = 2
97
75
}
98
76
77
+ # See https://registry.terraform.io/modules/terraform-google-modules/container-vm
99
78
module "gce-container" {
100
79
source = " terraform-google-modules/container-vm/google"
101
80
version = " 3.0.0"
@@ -111,7 +90,7 @@ module "gce-container" {
111
90
}
112
91
113
92
resource "google_compute_instance" "dev" {
114
- zone = data . coder_parameter . zone . value
93
+ zone = module . gcp_region . value
115
94
count = data. coder_workspace . me . start_count
116
95
name = " coder-${ lower (data. coder_workspace_owner . me . name )} -${ lower (data. coder_workspace . me . name )} "
117
96
machine_type = " e2-medium"
0 commit comments