Skip to content

feat(examples/templates/gcp-devcontainer): promote module usage #15549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 35 additions & 41 deletions examples/templates/gcp-devcontainer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ terraform {
provider "coder" {}

provider "google" {
zone = data.coder_parameter.zone.value
zone = module.gcp_region.value
project = var.project_id
}

Expand All @@ -41,40 +41,10 @@ variable "cache_repo_docker_config_path" {
type = string
}

data "coder_parameter" "zone" {
name = "zone"
display_name = "Zone"
description = "Which zone should your workspace live in?"
type = "string"
icon = "/emojis/1f30e.png"
default = "us-central1-a"
mutable = false
order = 1
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"
}
module "gcp_region" {
source = "registry.coder.com/modules/gcp-region/coder"
version = "1.0.12"
regions = ["us", "europe"]
}

data "coder_parameter" "instance_type" {
Expand Down Expand Up @@ -311,12 +281,36 @@ resource "coder_agent" "dev" {
}
}

# Install code-server via Terraform module.
# See https://registry.coder.com/modules/code-server
module "code-server" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/modules/code-server/coder"
version = "1.0.18"
agent_id = coder_agent.dev[0].id
count = data.coder_workspace.me.start_count
source = "registry.coder.com/modules/code-server/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"

agent_id = coder_agent.main.id
order = 1
}

# See https://registry.coder.com/modules/jetbrains-gateway
module "jetbrains_gateway" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/modules/jetbrains-gateway/coder"

# JetBrains IDEs to make available for the user to select
jetbrains_ides = ["IU", "PY", "WS", "PS", "RD", "CL", "GO", "RM"]
default = "IU"

# Default folder to open when starting a JetBrains IDE
folder = "/home/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"

agent_id = coder_agent.main.id
agent_name = "main"
order = 2
}

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

item {
key = "zone"
value = data.coder_parameter.zone.value
value = module.gcp_region.value
}
}

Expand Down
Loading