From 7a7db9f4ad2cf04355b70a483a30b994e0ee34b0 Mon Sep 17 00:00:00 2001 From: Phorcys <57866459+phorcys420@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:12:36 +0100 Subject: [PATCH] feat(examples/templates/gcp-windows): add GCP region module (#15552) --- examples/templates/gcp-windows/main.tf | 58 +++++++------------------- 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/examples/templates/gcp-windows/main.tf b/examples/templates/gcp-windows/main.tf index 74ff06109a..28f64ee232 100644 --- a/examples/templates/gcp-windows/main.tf +++ b/examples/templates/gcp-windows/main.tf @@ -9,64 +9,37 @@ terraform { } } -provider "coder" { -} +provider "coder" {} variable "project_id" { description = "Which Google Compute Project should your workspace live in?" } -data "coder_parameter" "zone" { - name = "zone" - display_name = "Zone" - description = "Which zone should your workspace live in?" - type = "string" - default = "us-central1-a" - icon = "/emojis/1f30e.png" - mutable = false - option { - name = "North America (Northeast)" - value = "northamerica-northeast1-a" - icon = "/emojis/1f1fa-1f1f8.png" - } - option { - name = "North America (Central)" - value = "us-central1-a" - icon = "/emojis/1f1fa-1f1f8.png" - } - option { - name = "North America (West)" - value = "us-west2-c" - icon = "/emojis/1f1fa-1f1f8.png" - } - option { - name = "Europe (West)" - value = "europe-west4-b" - icon = "/emojis/1f1ea-1f1fa.png" - } - option { - name = "South America (East)" - value = "southamerica-east1-a" - icon = "/emojis/1f1e7-1f1f7.png" - } +# See https://registry.coder.com/modules/gcp-region +module "gcp_region" { + source = "registry.coder.com/modules/gcp-region/coder" + + # This ensures that the latest version of the module gets downloaded, you can also pin the module version to prevent breaking changes in production. + version = ">= 1.0.0" + + regions = ["us", "europe"] + default = "us-central1-a" } provider "google" { - zone = data.coder_parameter.zone.value + zone = module.gcp_region.value project = var.project_id } -data "coder_workspace" "me" { -} +data "coder_workspace" "me" {} data "coder_workspace_owner" "me" {} -data "google_compute_default_service_account" "default" { -} +data "google_compute_default_service_account" "default" {} resource "google_compute_disk" "root" { name = "coder-${data.coder_workspace.me.id}-root" type = "pd-ssd" - zone = data.coder_parameter.zone.value + zone = module.gcp_region.value image = "projects/windows-cloud/global/images/windows-server-2022-dc-core-v20220215" lifecycle { ignore_changes = [name, image] @@ -77,11 +50,10 @@ resource "coder_agent" "main" { auth = "google-instance-identity" arch = "amd64" os = "windows" - } resource "google_compute_instance" "dev" { - zone = data.coder_parameter.zone.value + zone = module.gcp_region.value count = data.coder_workspace.me.start_count name = "coder-${lower(data.coder_workspace_owner.me.name)}-${lower(data.coder_workspace.me.name)}" machine_type = "e2-medium"