Skip to content

Commit 7a7db9f

Browse files
authored
feat(examples/templates/gcp-windows): add GCP region module (coder#15552)
1 parent 56eb722 commit 7a7db9f

File tree

1 file changed

+15
-43
lines changed
  • examples/templates/gcp-windows

1 file changed

+15
-43
lines changed

examples/templates/gcp-windows/main.tf

Lines changed: 15 additions & 43 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-
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+
# 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 "coder_workspace" "me" {
60-
}
34+
data "coder_workspace" "me" {}
6135
data "coder_workspace_owner" "me" {}
6236

63-
data "google_compute_default_service_account" "default" {
64-
}
37+
data "google_compute_default_service_account" "default" {}
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 = "projects/windows-cloud/global/images/windows-server-2022-dc-core-v20220215"
7144
lifecycle {
7245
ignore_changes = [name, image]
@@ -77,11 +50,10 @@ resource "coder_agent" "main" {
7750
auth = "google-instance-identity"
7851
arch = "amd64"
7952
os = "windows"
80-
8153
}
8254

8355
resource "google_compute_instance" "dev" {
84-
zone = data.coder_parameter.zone.value
56+
zone = module.gcp_region.value
8557
count = data.coder_workspace.me.start_count
8658
name = "coder-${lower(data.coder_workspace_owner.me.name)}-${lower(data.coder_workspace.me.name)}"
8759
machine_type = "e2-medium"

0 commit comments

Comments
 (0)