Skip to content

Commit 0b4eb8b

Browse files
authored
feat(examples/templates/gcp-devcontainer): promote module usage (#15549)
1 parent 68dc820 commit 0b4eb8b

File tree

1 file changed

+35
-41
lines changed
  • examples/templates/gcp-devcontainer

1 file changed

+35
-41
lines changed

examples/templates/gcp-devcontainer/main.tf

+35-41
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ terraform {
1515
provider "coder" {}
1616

1717
provider "google" {
18-
zone = data.coder_parameter.zone.value
18+
zone = module.gcp_region.value
1919
project = var.project_id
2020
}
2121

@@ -41,40 +41,10 @@ variable "cache_repo_docker_config_path" {
4141
type = string
4242
}
4343

44-
data "coder_parameter" "zone" {
45-
name = "zone"
46-
display_name = "Zone"
47-
description = "Which zone should your workspace live in?"
48-
type = "string"
49-
icon = "/emojis/1f30e.png"
50-
default = "us-central1-a"
51-
mutable = false
52-
order = 1
53-
option {
54-
name = "North America (Northeast)"
55-
value = "northamerica-northeast1-a"
56-
icon = "/emojis/1f1fa-1f1f8.png"
57-
}
58-
option {
59-
name = "North America (Central)"
60-
value = "us-central1-a"
61-
icon = "/emojis/1f1fa-1f1f8.png"
62-
}
63-
option {
64-
name = "North America (West)"
65-
value = "us-west2-c"
66-
icon = "/emojis/1f1fa-1f1f8.png"
67-
}
68-
option {
69-
name = "Europe (West)"
70-
value = "europe-west4-b"
71-
icon = "/emojis/1f1ea-1f1fa.png"
72-
}
73-
option {
74-
name = "South America (East)"
75-
value = "southamerica-east1-a"
76-
icon = "/emojis/1f1e7-1f1f7.png"
77-
}
44+
module "gcp_region" {
45+
source = "registry.coder.com/modules/gcp-region/coder"
46+
version = "1.0.12"
47+
regions = ["us", "europe"]
7848
}
7949

8050
data "coder_parameter" "instance_type" {
@@ -311,12 +281,36 @@ resource "coder_agent" "dev" {
311281
}
312282
}
313283

314-
# Install code-server via Terraform module.
284+
# See https://registry.coder.com/modules/code-server
315285
module "code-server" {
316-
count = data.coder_workspace.me.start_count
317-
source = "registry.coder.com/modules/code-server/coder"
318-
version = "1.0.18"
319-
agent_id = coder_agent.dev[0].id
286+
count = data.coder_workspace.me.start_count
287+
source = "registry.coder.com/modules/code-server/coder"
288+
289+
# This ensures that the latest version of the module gets downloaded, you can also pin the module version to prevent breaking changes in production.
290+
version = ">= 1.0.0"
291+
292+
agent_id = coder_agent.main.id
293+
order = 1
294+
}
295+
296+
# See https://registry.coder.com/modules/jetbrains-gateway
297+
module "jetbrains_gateway" {
298+
count = data.coder_workspace.me.start_count
299+
source = "registry.coder.com/modules/jetbrains-gateway/coder"
300+
301+
# JetBrains IDEs to make available for the user to select
302+
jetbrains_ides = ["IU", "PY", "WS", "PS", "RD", "CL", "GO", "RM"]
303+
default = "IU"
304+
305+
# Default folder to open when starting a JetBrains IDE
306+
folder = "/home/coder"
307+
308+
# This ensures that the latest version of the module gets downloaded, you can also pin the module version to prevent breaking changes in production.
309+
version = ">= 1.0.0"
310+
311+
agent_id = coder_agent.main.id
312+
agent_name = "main"
313+
order = 2
320314
}
321315

322316
# Create metadata for the workspace and home disk.
@@ -331,7 +325,7 @@ resource "coder_metadata" "workspace_info" {
331325

332326
item {
333327
key = "zone"
334-
value = data.coder_parameter.zone.value
328+
value = module.gcp_region.value
335329
}
336330
}
337331

0 commit comments

Comments
 (0)