Skip to content

Commit 946328f

Browse files
authored
feat(examples/templates/gcp-linux): add GCP region, code-server and JetBrains Gateway modules (#15550)
1 parent ba91a95 commit 946328f

File tree

1 file changed

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

1 file changed

+46
-63
lines changed

examples/templates/gcp-linux/main.tf

Lines changed: 46 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,64 +9,37 @@ 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+
# 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"
5227
}
5328

5429
provider "google" {
55-
zone = data.coder_parameter.zone.value
30+
zone = module.gcp_region.value
5631
project = var.project_id
5732
}
5833

59-
data "google_compute_default_service_account" "default" {
60-
}
34+
data "google_compute_default_service_account" "default" {}
6135

62-
data "coder_workspace" "me" {
63-
}
36+
data "coder_workspace" "me" {}
6437
data "coder_workspace_owner" "me" {}
6538

6639
resource "google_compute_disk" "root" {
6740
name = "coder-${data.coder_workspace.me.id}-root"
6841
type = "pd-ssd"
69-
zone = data.coder_parameter.zone.value
42+
zone = module.gcp_region.value
7043
image = "debian-cloud/debian-11"
7144
lifecycle {
7245
ignore_changes = [name, image]
@@ -80,12 +53,7 @@ resource "coder_agent" "main" {
8053
startup_script = <<-EOT
8154
set -e
8255
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
8957
EOT
9058

9159
metadata {
@@ -123,25 +91,40 @@ resource "coder_agent" "main" {
12391
}
12492
}
12593

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
141124
}
142125

143126
resource "google_compute_instance" "dev" {
144-
zone = data.coder_parameter.zone.value
127+
zone = module.gcp_region.value
145128
count = data.coder_workspace.me.start_count
146129
name = "coder-${lower(data.coder_workspace_owner.me.name)}-${lower(data.coder_workspace.me.name)}-root"
147130
machine_type = "e2-medium"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy