Skip to content

feat(examples/templates/azure-linux): promote module usage #15517

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 2 commits into from
Nov 18, 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
182 changes: 42 additions & 140 deletions examples/templates/azure-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,143 +9,14 @@ terraform {
}
}

data "coder_parameter" "location" {
name = "location"
display_name = "Location"
description = "What location should your workspace live in?"
default = "eastus"
icon = "/emojis/1f310.png"
mutable = false
option {
name = "US (Virginia)"
value = "eastus"
icon = "/emojis/1f1fa-1f1f8.png"
}
option {
name = "US (Virginia) 2"
value = "eastus2"
icon = "/emojis/1f1fa-1f1f8.png"
}
option {
name = "US (Texas)"
value = "southcentralus"
icon = "/emojis/1f1fa-1f1f8.png"
}
option {
name = "US (Washington)"
value = "westus2"
icon = "/emojis/1f1fa-1f1f8.png"
}
option {
name = "US (Arizona)"
value = "westus3"
icon = "/emojis/1f1fa-1f1f8.png"
}
option {
name = "US (Iowa)"
value = "centralus"
icon = "/emojis/1f1fa-1f1f8.png"
}
option {
name = "Canada (Toronto)"
value = "canadacentral"
icon = "/emojis/1f1e8-1f1e6.png"
}
option {
name = "Brazil (Sao Paulo)"
value = "brazilsouth"
icon = "/emojis/1f1e7-1f1f7.png"
}
option {
name = "East Asia (Hong Kong)"
value = "eastasia"
icon = "/emojis/1f1f0-1f1f7.png"
}
option {
name = "Southeast Asia (Singapore)"
value = "southeastasia"
icon = "/emojis/1f1f0-1f1f7.png"
}
option {
name = "Australia (New South Wales)"
value = "australiaeast"
icon = "/emojis/1f1e6-1f1fa.png"
}
option {
name = "China (Hebei)"
value = "chinanorth3"
icon = "/emojis/1f1e8-1f1f3.png"
}
option {
name = "India (Pune)"
value = "centralindia"
icon = "/emojis/1f1ee-1f1f3.png"
}
option {
name = "Japan (Tokyo)"
value = "japaneast"
icon = "/emojis/1f1ef-1f1f5.png"
}
option {
name = "Korea (Seoul)"
value = "koreacentral"
icon = "/emojis/1f1f0-1f1f7.png"
}
option {
name = "Europe (Ireland)"
value = "northeurope"
icon = "/emojis/1f1ea-1f1fa.png"
}
option {
name = "Europe (Netherlands)"
value = "westeurope"
icon = "/emojis/1f1ea-1f1fa.png"
}
option {
name = "France (Paris)"
value = "francecentral"
icon = "/emojis/1f1eb-1f1f7.png"
}
option {
name = "Germany (Frankfurt)"
value = "germanywestcentral"
icon = "/emojis/1f1e9-1f1ea.png"
}
option {
name = "Norway (Oslo)"
value = "norwayeast"
icon = "/emojis/1f1f3-1f1f4.png"
}
option {
name = "Sweden (Gävle)"
value = "swedencentral"
icon = "/emojis/1f1f8-1f1ea.png"
}
option {
name = "Switzerland (Zurich)"
value = "switzerlandnorth"
icon = "/emojis/1f1e8-1f1ed.png"
}
option {
name = "Qatar (Doha)"
value = "qatarcentral"
icon = "/emojis/1f1f6-1f1e6.png"
}
option {
name = "UAE (Dubai)"
value = "uaenorth"
icon = "/emojis/1f1e6-1f1ea.png"
}
option {
name = "South Africa (Johannesburg)"
value = "southafricanorth"
icon = "/emojis/1f1ff-1f1e6.png"
}
option {
name = "UK (London)"
value = "uksouth"
icon = "/emojis/1f1ec-1f1e7.png"
}
# See https://registry.coder.com/modules/azure-region
module "azure_region" {
source = "registry.coder.com/modules/azure-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"

default = "eastus"
}

data "coder_parameter" "instance_type" {
Expand Down Expand Up @@ -219,8 +90,7 @@ provider "azurerm" {
features {}
}

data "coder_workspace" "me" {
}
data "coder_workspace" "me" {}
data "coder_workspace_owner" "me" {}

resource "coder_agent" "main" {
Expand Down Expand Up @@ -263,6 +133,38 @@ resource "coder_agent" "main" {
}
}

# 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"

# 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
}

locals {
prefix = "coder-${data.coder_workspace_owner.me.name}-${data.coder_workspace.me.name}"

Expand All @@ -275,7 +177,7 @@ locals {

resource "azurerm_resource_group" "main" {
name = "${local.prefix}-resources"
location = data.coder_parameter.location.value
location = module.azure_region.value

tags = {
Coder_Provisioned = "true"
Expand Down
Loading