Skip to content

Commit 41c1e94

Browse files
committed
feat: promote modules
1 parent 968c52b commit 41c1e94

File tree

1 file changed

+41
-63
lines changed
  • examples/templates/gcp-linux

1 file changed

+41
-63
lines changed

examples/templates/gcp-linux/main.tf

Lines changed: 41 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,64 +9,32 @@ terraform {
99
}
1010
}
1111

12-
provider "coder" {
13-
}
12+
provider "coder" {}
1413

1514
variable "project_id" {
1615
description = "Which Google Compute Project should your workspace live in?"
1716
}
1817

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+
module "gcp_region" {
19+
source = "registry.coder.com/modules/gcp-region/coder"
20+
version = "1.0.12"
21+
regions = ["us", "europe"]
5222
}
5323

5424
provider "google" {
55-
zone = data.coder_parameter.zone.value
25+
zone = module.gcp_region.value
5626
project = var.project_id
5727
}
5828

59-
data "google_compute_default_service_account" "default" {
60-
}
29+
data "google_compute_default_service_account" "default" {}
6130

62-
data "coder_workspace" "me" {
63-
}
31+
data "coder_workspace" "me" {}
6432
data "coder_workspace_owner" "me" {}
6533

6634
resource "google_compute_disk" "root" {
6735
name = "coder-${data.coder_workspace.me.id}-root"
6836
type = "pd-ssd"
69-
zone = data.coder_parameter.zone.value
37+
zone = module.gcp_region.value
7038
image = "debian-cloud/debian-11"
7139
lifecycle {
7240
ignore_changes = [name, image]
@@ -80,12 +48,7 @@ resource "coder_agent" "main" {
8048
startup_script = <<-EOT
8149
set -e
8250
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 &
51+
# Add any commands that should be executed at workspace startup (e.g install requirements, start a program, etc) here
8952
EOT
9053

9154
metadata {
@@ -123,25 +86,40 @@ resource "coder_agent" "main" {
12386
}
12487
}
12588

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-
}
89+
# See https://registry.coder.com/modules/code-server
90+
module "code-server" {
91+
count = data.coder_workspace.me.start_count
92+
source = "registry.coder.com/modules/code-server/coder"
93+
94+
# This ensures that the latest version of the module gets downloaded, you can also pin the module version to prevent breaking changes in production.
95+
version = ">= 1.0.0"
96+
97+
agent_id = coder_agent.main.id
98+
order = 1
99+
}
100+
101+
# See https://registry.coder.com/modules/jetbrains-gateway
102+
module "jetbrains_gateway" {
103+
count = data.coder_workspace.me.start_count
104+
source = "registry.coder.com/modules/jetbrains-gateway/coder"
105+
106+
# JetBrains IDEs to make available for the user to select
107+
jetbrains_ides = ["IU", "PY", "WS", "PS", "RD", "CL", "GO", "RM"]
108+
default = "IU"
109+
110+
# Default folder to open when starting a JetBrains IDE
111+
folder = "/home/coder"
112+
113+
# This ensures that the latest version of the module gets downloaded, you can also pin the module version to prevent breaking changes in production.
114+
version = ">= 1.0.0"
115+
116+
agent_id = coder_agent.main.id
117+
agent_name = "main"
118+
order = 2
141119
}
142120

143121
resource "google_compute_instance" "dev" {
144-
zone = data.coder_parameter.zone.value
122+
zone = module.gcp_region.value
145123
count = data.coder_workspace.me.start_count
146124
name = "coder-${lower(data.coder_workspace_owner.me.name)}-${lower(data.coder_workspace.me.name)}-root"
147125
machine_type = "e2-medium"

0 commit comments

Comments
 (0)