diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf
index ce30acd39037e..e7869b1c270a5 100644
--- a/examples/templates/aws-ecs-container/main.tf
+++ b/examples/templates/aws-ecs-container/main.tf
@@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
aws = {
source = "hashicorp/aws"
@@ -11,16 +11,28 @@ terraform {
}
}
+provider "coder" {
+ feature_use_managed_variables = true
+}
+
variable "ecs-cluster" {
description = "Input the ECS cluster ARN to host the workspace"
- default = ""
}
-variable "cpu" {
- default = "1024"
+
+data "coder_parameter" "cpu" {
+ name = "cpu"
+ description = "The number of CPU units to reserve for the container"
+ type = "number"
+ default = "1024"
+ mutable = true
}
-variable "memory" {
- default = "2048"
+data "coder_parameter" "memory" {
+ name = "memory"
+ description = "The amount of memory (in MiB) to allow the container to use"
+ type = "number"
+ default = "2048"
+ mutable = true
}
# configure AWS provider with creds present on Coder server host
@@ -34,14 +46,14 @@ resource "aws_ecs_task_definition" "workspace" {
family = "coder"
requires_compatibilities = ["EC2"]
- cpu = var.cpu
- memory = var.memory
+ cpu = data.coder_parameter.cpu.value
+ memory = data.coder_parameter.memory.value
container_definitions = jsonencode([
{
name = "coder-workspace-${data.coder_workspace.me.id}"
image = "codercom/enterprise-base:ubuntu"
- cpu = 1024
- memory = 2048
+ cpu = tonumber(data.coder_parameter.cpu.value)
+ memory = tonumber(data.coder_parameter.memory.value)
essential = true
user = "coder"
command = ["sh", "-c", coder_agent.coder.init_script]
@@ -92,11 +104,10 @@ resource "aws_ecs_service" "workspace" {
data "coder_workspace" "me" {}
resource "coder_agent" "coder" {
- arch = "amd64"
- auth = "token"
- os = "linux"
- dir = "/home/coder"
-
+ arch = "amd64"
+ auth = "token"
+ os = "linux"
+ dir = "/home/coder"
login_before_ready = false
startup_script_timeout = 180
startup_script = <<-EOT
diff --git a/examples/templates/aws-linux/main.tf b/examples/templates/aws-linux/main.tf
index 7534163365e3a..986a1088a17cb 100644
--- a/examples/templates/aws-linux/main.tf
+++ b/examples/templates/aws-linux/main.tf
@@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
aws = {
source = "hashicorp/aws"
@@ -11,53 +11,133 @@ terraform {
}
}
-# Last updated 2022-05-31
+# Last updated 2023-03-14
# aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort'
-variable "region" {
- description = "What region should your workspace live in?"
+data "coder_parameter" "region" {
+ name = "Region"
+ description = "The region to deploy the workspace in."
default = "us-east-1"
- validation {
- condition = contains([
- "ap-northeast-1",
- "ap-northeast-2",
- "ap-northeast-3",
- "ap-south-1",
- "ap-southeast-1",
- "ap-southeast-2",
- "ca-central-1",
- "eu-central-1",
- "eu-north-1",
- "eu-west-1",
- "eu-west-2",
- "eu-west-3",
- "sa-east-1",
- "us-east-1",
- "us-east-2",
- "us-west-1",
- "us-west-2"
- ], var.region)
- error_message = "Invalid region!"
+ mutable = false
+ option {
+ name = "Asia Pacific (Tokyo)"
+ value = "ap-northeast-1"
+ icon = "/emojis/1f1ef-1f1f5.png"
+ }
+ option {
+ name = "Asia Pacific (Seoul)"
+ value = "ap-northeast-2"
+ icon = "/emojis/1f1f0-1f1f7.png"
+ }
+ option {
+ name = "Asia Pacific (Osaka-Local)"
+ value = "ap-northeast-3"
+ icon = "/emojis/1f1f0-1f1f7.png"
+ }
+ option {
+ name = "Asia Pacific (Mumbai)"
+ value = "ap-south-1"
+ icon = "/emojis/1f1f0-1f1f7.png"
+ }
+ option {
+ name = "Asia Pacific (Singapore)"
+ value = "ap-southeast-1"
+ icon = "/emojis/1f1f0-1f1f7.png"
+ }
+ option {
+ name = "Asia Pacific (Sydney)"
+ value = "ap-southeast-2"
+ icon = "/emojis/1f1f0-1f1f7.png"
+ }
+ option {
+ name = "Canada (Central)"
+ value = "ca-central-1"
+ icon = "/emojis/1f1e8-1f1e6.png"
+ }
+ option {
+ name = "EU (Frankfurt)"
+ value = "eu-central-1"
+ icon = "/emojis/1f1ea-1f1fa.png"
+ }
+ option {
+ name = "EU (Stockholm)"
+ value = "eu-north-1"
+ icon = "/emojis/1f1ea-1f1fa.png"
+ }
+ option {
+ name = "EU (Ireland)"
+ value = "eu-west-1"
+ icon = "/emojis/1f1ea-1f1fa.png"
+ }
+ option {
+ name = "EU (London)"
+ value = "eu-west-2"
+ icon = "/emojis/1f1ea-1f1fa.png"
+ }
+ option {
+ name = "EU (Paris)"
+ value = "eu-west-3"
+ icon = "/emojis/1f1ea-1f1fa.png"
+ }
+ option {
+ name = "South America (São Paulo)"
+ value = "sa-east-1"
+ icon = "/emojis/1f1e7-1f1f7.png"
+ }
+ option {
+ name = "US East (N. Virginia)"
+ value = "us-east-1"
+ icon = "/emojis/1f1fa-1f1f8.png"
+ }
+ option {
+ name = "US East (Ohio)"
+ value = "us-east-2"
+ icon = "/emojis/1f1fa-1f1f8.png"
+ }
+ option {
+ name = "US West (N. California)"
+ value = "us-west-1"
+ icon = "/emojis/1f1fa-1f1f8.png"
+ }
+ option {
+ name = "US West (Oregon)"
+ value = "us-west-2"
+ icon = "/emojis/1f1fa-1f1f8.png"
}
}
-variable "instance_type" {
+data "coder_parameter" "instance_type" {
+ name = "Instance Type"
description = "What instance type should your workspace use?"
default = "t3.micro"
- validation {
- condition = contains([
- "t3.micro",
- "t3.small",
- "t3.medium",
- "t3.large",
- "t3.xlarge",
- "t3.2xlarge",
- ], var.instance_type)
- error_message = "Invalid instance type!"
+ mutable = false
+ option {
+ name = "2 vCPU, 1 GiB RAM"
+ value = "t3.micro"
+ }
+ option {
+ name = "2 vCPU, 2 GiB RAM"
+ value = "t3.small"
+ }
+ option {
+ name = "2 vCPU, 4 GiB RAM"
+ value = "t3.medium"
+ }
+ option {
+ name = "2 vCPU, 8 GiB RAM"
+ value = "t3.large"
+ }
+ option {
+ name = "4 vCPU, 16 GiB RAM"
+ value = "t3.xlarge"
+ }
+ option {
+ name = "8 vCPU, 32 GiB RAM"
+ value = "t3.2xlarge"
}
}
provider "aws" {
- region = var.region
+ region = data.coder_parameter.region.value
}
data "coder_workspace" "me" {
@@ -77,10 +157,9 @@ data "aws_ami" "ubuntu" {
}
resource "coder_agent" "main" {
- arch = "amd64"
- auth = "aws-instance-identity"
- os = "linux"
-
+ arch = "amd64"
+ auth = "aws-instance-identity"
+ os = "linux"
login_before_ready = false
startup_script_timeout = 180
startup_script = <<-EOT
@@ -174,8 +253,8 @@ EOT
resource "aws_instance" "dev" {
ami = data.aws_ami.ubuntu.id
- availability_zone = "${var.region}a"
- instance_type = var.instance_type
+ availability_zone = "${data.coder_parameter.region.value}a"
+ instance_type = data.coder_parameter.instance_type.value
user_data = data.coder_workspace.me.transition == "start" ? local.user_data_start : local.user_data_end
tags = {
@@ -189,7 +268,7 @@ resource "coder_metadata" "workspace_info" {
resource_id = aws_instance.dev.id
item {
key = "region"
- value = var.region
+ value = data.coder_parameter.region.value
}
item {
key = "instance type"
diff --git a/examples/templates/aws-windows/main.tf b/examples/templates/aws-windows/main.tf
index ff97d34e3bec7..87c5b710a2c97 100644
--- a/examples/templates/aws-windows/main.tf
+++ b/examples/templates/aws-windows/main.tf
@@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
aws = {
source = "hashicorp/aws"
@@ -11,53 +11,133 @@ terraform {
}
}
-# Last updated 2022-05-31
+# Last updated 2023-03-14
# aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort'
-variable "region" {
- description = "What region should your workspace live in?"
+data "coder_parameter" "region" {
+ name = "Region"
+ description = "The region to deploy the workspace in."
default = "us-east-1"
- validation {
- condition = contains([
- "ap-northeast-1",
- "ap-northeast-2",
- "ap-northeast-3",
- "ap-south-1",
- "ap-southeast-1",
- "ap-southeast-2",
- "ca-central-1",
- "eu-central-1",
- "eu-north-1",
- "eu-west-1",
- "eu-west-2",
- "eu-west-3",
- "sa-east-1",
- "us-east-1",
- "us-east-2",
- "us-west-1",
- "us-west-2"
- ], var.region)
- error_message = "Invalid region!"
+ mutable = false
+ option {
+ name = "Asia Pacific (Tokyo)"
+ value = "ap-northeast-1"
+ icon = "/emojis/1f1ef-1f1f5.png"
+ }
+ option {
+ name = "Asia Pacific (Seoul)"
+ value = "ap-northeast-2"
+ icon = "/emojis/1f1f0-1f1f7.png"
+ }
+ option {
+ name = "Asia Pacific (Osaka-Local)"
+ value = "ap-northeast-3"
+ icon = "/emojis/1f1f0-1f1f7.png"
+ }
+ option {
+ name = "Asia Pacific (Mumbai)"
+ value = "ap-south-1"
+ icon = "/emojis/1f1f0-1f1f7.png"
+ }
+ option {
+ name = "Asia Pacific (Singapore)"
+ value = "ap-southeast-1"
+ icon = "/emojis/1f1f0-1f1f7.png"
+ }
+ option {
+ name = "Asia Pacific (Sydney)"
+ value = "ap-southeast-2"
+ icon = "/emojis/1f1f0-1f1f7.png"
+ }
+ option {
+ name = "Canada (Central)"
+ value = "ca-central-1"
+ icon = "/emojis/1f1e8-1f1e6.png"
+ }
+ option {
+ name = "EU (Frankfurt)"
+ value = "eu-central-1"
+ icon = "/emojis/1f1ea-1f1fa.png"
+ }
+ option {
+ name = "EU (Stockholm)"
+ value = "eu-north-1"
+ icon = "/emojis/1f1ea-1f1fa.png"
+ }
+ option {
+ name = "EU (Ireland)"
+ value = "eu-west-1"
+ icon = "/emojis/1f1ea-1f1fa.png"
+ }
+ option {
+ name = "EU (London)"
+ value = "eu-west-2"
+ icon = "/emojis/1f1ea-1f1fa.png"
+ }
+ option {
+ name = "EU (Paris)"
+ value = "eu-west-3"
+ icon = "/emojis/1f1ea-1f1fa.png"
+ }
+ option {
+ name = "South America (São Paulo)"
+ value = "sa-east-1"
+ icon = "/emojis/1f1e7-1f1f7.png"
+ }
+ option {
+ name = "US East (N. Virginia)"
+ value = "us-east-1"
+ icon = "/emojis/1f1fa-1f1f8.png"
+ }
+ option {
+ name = "US East (Ohio)"
+ value = "us-east-2"
+ icon = "/emojis/1f1fa-1f1f8.png"
+ }
+ option {
+ name = "US West (N. California)"
+ value = "us-west-1"
+ icon = "/emojis/1f1fa-1f1f8.png"
+ }
+ option {
+ name = "US West (Oregon)"
+ value = "us-west-2"
+ icon = "/emojis/1f1fa-1f1f8.png"
}
}
-variable "instance_type" {
+data "coder_parameter" "instance_type" {
+ name = "Instance Type"
description = "What instance type should your workspace use?"
default = "t3.micro"
- validation {
- condition = contains([
- "t3.micro",
- "t3.small",
- "t3.medium",
- "t3.large",
- "t3.xlarge",
- "t3.2xlarge",
- ], var.instance_type)
- error_message = "Invalid instance type!"
+ mutable = false
+ option {
+ name = "2 vCPU, 1 GiB RAM"
+ value = "t3.micro"
+ }
+ option {
+ name = "2 vCPU, 2 GiB RAM"
+ value = "t3.small"
+ }
+ option {
+ name = "2 vCPU, 4 GiB RAM"
+ value = "t3.medium"
+ }
+ option {
+ name = "2 vCPU, 8 GiB RAM"
+ value = "t3.large"
+ }
+ option {
+ name = "4 vCPU, 16 GiB RAM"
+ value = "t3.xlarge"
+ }
+ option {
+ name = "8 vCPU, 32 GiB RAM"
+ value = "t3.2xlarge"
}
}
provider "aws" {
- region = var.region
+ region = data.coder_parameter.region.value
}
data "coder_workspace" "me" {
@@ -74,10 +154,9 @@ data "aws_ami" "windows" {
}
resource "coder_agent" "main" {
- arch = "amd64"
- auth = "aws-instance-identity"
- os = "windows"
-
+ arch = "amd64"
+ auth = "aws-instance-identity"
+ os = "windows"
login_before_ready = false
}
@@ -104,9 +183,8 @@ EOT
resource "aws_instance" "dev" {
ami = data.aws_ami.windows.id
- availability_zone = "${var.region}a"
- instance_type = var.instance_type
- count = 1
+ availability_zone = "${data.coder_parameter.region.value}a"
+ instance_type = data.coder_parameter.instance_type.value
user_data = data.coder_workspace.me.transition == "start" ? local.user_data_start : local.user_data_end
tags = {
@@ -114,14 +192,13 @@ resource "aws_instance" "dev" {
# Required if you are using our example policy, see template README
Coder_Provisioned = "true"
}
-
}
resource "coder_metadata" "workspace_info" {
resource_id = aws_instance.dev.id
item {
key = "region"
- value = var.region
+ value = data.coder_parameter.region.value
}
item {
key = "instance type"
diff --git a/examples/templates/azure-linux/main.tf b/examples/templates/azure-linux/main.tf
index b5a3ae04c827b..7360ac9381f70 100644
--- a/examples/templates/azure-linux/main.tf
+++ b/examples/templates/azure-linux/main.tf
@@ -2,73 +2,215 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
azurerm = {
source = "hashicorp/azurerm"
- version = "=3.0.0"
+ version = "~>3.47.0"
}
}
}
-variable "location" {
+data "coder_parameter" "location" {
+ name = "Location"
description = "What location should your workspace live in?"
default = "eastus"
- validation {
- condition = contains([
- "eastus",
- "southcentralus",
- "westus2",
- "australiaeast",
- "southeastasia",
- "northeurope",
- "westeurope",
- "centralindia",
- "eastasia",
- "japaneast",
- "brazilsouth",
- "asia",
- "asiapacific",
- "australia",
- "brazil",
- "india",
- "japan",
- "southafrica",
- "switzerland",
- "uae",
- ], var.location)
- error_message = "Invalid location!"
- }
-}
-
-variable "instance_type" {
+ 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"
+ }
+}
+
+data "coder_parameter" "instance_type" {
+ name = "Instance Type"
description = "What instance type should your workspace use?"
default = "Standard_B4ms"
- validation {
- condition = contains([
- "Standard_B1ms",
- "Standard_B2ms",
- "Standard_B4ms",
- "Standard_B8ms",
- "Standard_B12ms",
- "Standard_B16ms",
- "Standard_D2as_v5",
- "Standard_D4as_v5",
- "Standard_D8as_v5",
- "Standard_D16as_v5",
- "Standard_D32as_v5",
- ], var.instance_type)
- error_message = "Invalid instance type!"
- }
-}
-
-variable "home_size" {
- type = number
+ icon = "/icon/azure.png"
+ mutable = false
+ option {
+ name = "Standard_B1ms (1 vCPU, 2 GiB RAM)"
+ value = "Standard_B1ms"
+ }
+ option {
+ name = "Standard_B2ms (2 vCPU, 8 GiB RAM)"
+ value = "Standard_B2ms"
+ }
+ option {
+ name = "Standard_B4ms (4 vCPU, 16 GiB RAM)"
+ value = "Standard_B4ms"
+ }
+ option {
+ name = "Standard_B8ms (8 vCPU, 32 GiB RAM)"
+ value = "Standard_B8ms"
+ }
+ option {
+ name = "Standard_B12ms (12 vCPU, 48 GiB RAM)"
+ value = "Standard_B12ms"
+ }
+ option {
+ name = "Standard_B16ms (16 vCPU, 64 GiB RAM)"
+ value = "Standard_B16ms"
+ }
+ option {
+ name = "Standard_D2as_v5 (2 vCPU, 8 GiB RAM)"
+ value = "Standard_D2as_v5"
+ }
+ option {
+ name = "Standard_D4as_v5 (4 vCPU, 16 GiB RAM)"
+ value = "Standard_D4as_v5"
+ }
+ option {
+ name = "Standard_D8as_v5 (8 vCPU, 32 GiB RAM)"
+ value = "Standard_D8as_v5"
+ }
+ option {
+ name = "Standard_D16as_v5 (16 vCPU, 64 GiB RAM)"
+ value = "Standard_D16as_v5"
+ }
+ option {
+ name = "Standard_D32as_v5 (32 vCPU, 128 GiB RAM)"
+ value = "Standard_D32as_v5"
+ }
+}
+
+data "coder_parameter" "home_size" {
+ name = "Home Volume Size"
description = "How large would you like your home volume to be (in GB)?"
default = 20
+ type = "number"
+ icon = "/icon/azure.png"
+ mutable = false
validation {
- condition = var.home_size >= 1
- error_message = "Value must be greater than or equal to 1."
+ min = 1
+ max = 1024
}
}
@@ -80,10 +222,9 @@ data "coder_workspace" "me" {
}
resource "coder_agent" "main" {
- arch = "amd64"
- os = "linux"
- auth = "azure-instance-identity"
-
+ arch = "amd64"
+ os = "linux"
+ auth = "azure-instance-identity"
login_before_ready = false
}
@@ -99,7 +240,7 @@ locals {
resource "azurerm_resource_group" "main" {
name = "${local.prefix}-resources"
- location = var.location
+ location = data.coder_parameter.location.value
tags = {
Coder_Provisioned = "true"
@@ -160,7 +301,7 @@ resource "azurerm_managed_disk" "home" {
name = "home"
resource_group_name = azurerm_resource_group.main.name
storage_account_type = "StandardSSD_LRS"
- disk_size_gb = var.home_size
+ disk_size_gb = data.coder_parameter.home_size.value
}
// azurerm requires an SSH key (or password) for an admin user or it won't start a VM. However,
@@ -175,7 +316,7 @@ resource "azurerm_linux_virtual_machine" "main" {
name = "vm"
resource_group_name = azurerm_resource_group.main.name
location = azurerm_resource_group.main.location
- size = var.instance_type
+ size = data.coder_parameter.instance_type.value
// cloud-init overwrites this, so the value here doesn't matter
admin_username = "adminuser"
admin_ssh_key {
@@ -227,6 +368,6 @@ resource "coder_metadata" "home_info" {
item {
key = "size"
- value = "${var.home_size} GiB"
+ value = "${data.coder_parameter.home_size.value} GiB"
}
}
diff --git a/examples/templates/do-linux/main.tf b/examples/templates/do-linux/main.tf
index edf31448b2b57..b87d91d0d4172 100644
--- a/examples/templates/do-linux/main.tf
+++ b/examples/templates/do-linux/main.tf
@@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
digitalocean = {
source = "digitalocean/digitalocean"
@@ -11,6 +11,10 @@ terraform {
}
}
+provider "coder" {
+ feature_use_managed_variables = true
+}
+
variable "step1_do_project_id" {
type = string
description = <<-EOF
@@ -21,9 +25,11 @@ variable "step1_do_project_id" {
sensitive = true
validation {
+ # make sure length of alphanumeric string is 36
condition = length(var.step1_do_project_id) == 36
error_message = "Invalid Digital Ocean Project ID."
}
+
}
variable "step2_do_admin_ssh_key" {
@@ -45,43 +51,179 @@ variable "step2_do_admin_ssh_key" {
}
}
-variable "droplet_image" {
- type = string
- description = "Which Droplet image would you like to use for your workspace?"
- default = "ubuntu-22-04-x64"
- validation {
- condition = contains(["ubuntu-22-04-x64", "ubuntu-20-04-x64", "fedora-36-x64", "fedora-35-x64", "debian-11-x64", "debian-10-x64", "centos-stream-9-x64", "centos-stream-8-x64", "rockylinux-8-x64", "rockylinux-8-4-x64"], var.droplet_image)
- error_message = "Value must be ubuntu-22-04-x64, ubuntu-20-04-x64, fedora-36-x64, fedora-35-x64, debian-11-x64, debian-10-x64, centos-stream-9-x64, centos-stream-8-x64, rockylinux-8-x64 or rockylinux-8-4-x64."
+data "coder_parameter" "droplet_image" {
+ name = "Which Droplet image would you like to use for your workspace?"
+ default = "ubuntu-22-04-x64"
+ type = "string"
+ mutable = false
+ option {
+ name = "Ubuntu 22.04"
+ value = "ubuntu-22-04-x64"
+ icon = "/icon/ubuntu.svg"
+ }
+ option {
+ name = "Ubuntu 20.04"
+ value = "ubuntu-20-04-x64"
+ icon = "/icon/ubuntu.svg"
+ }
+ option {
+ name = "Fedora 36"
+ value = "fedora-36-x64"
+ icon = "/icon/fedora.svg"
+ }
+ option {
+ name = "Fedora 35"
+ value = "fedora-35-x64"
+ icon = "/icon/fedora.svg"
+ }
+ option {
+ name = "Debian 11"
+ value = "debian-11-x64"
+ icon = "/icon/debian.svg"
+ }
+ option {
+ name = "Debian 10"
+ value = "debian-10-x64"
+ icon = "/icon/debian.svg"
+ }
+ option {
+ name = "CentOS Stream 9"
+ value = "centos-stream-9-x64"
+ icon = "/icon/centos.svg"
+ }
+ option {
+ name = "CentOS Stream 8"
+ value = "centos-stream-8-x64"
+ icon = "/icon/centos.svg"
+ }
+ option {
+ name = "Rocky Linux 8"
+ value = "rockylinux-8-x64"
+ icon = "/icon/rockylinux.svg"
+ }
+ option {
+ name = "Rocky Linux 8.4"
+ value = "rockylinux-8-4-x64"
+ icon = "/icon/rockylinux.svg"
}
}
-variable "droplet_size" {
- type = string
- description = "Which Droplet configuration would you like to use?"
- default = "s-1vcpu-1gb"
- validation {
- condition = contains(["s-1vcpu-1gb", "s-1vcpu-2gb", "s-2vcpu-2gb", "s-2vcpu-4gb", "s-4vcpu-8gb", "s-8vcpu-16gb"], var.droplet_size)
- error_message = "Value must be s-1vcpu-1gb, s-1vcpu-2gb, s-2vcpu-2gb, s-2vcpu-4gb, s-4vcpu-8gb or s-8vcpu-16gb."
+data "coder_parameter" "droplet_size" {
+ name = "Which Droplet configuration would you like to use?"
+ default = "s-1vcpu-1gb"
+ type = "string"
+ icon = "/icon/memory.svg"
+ mutable = false
+ option {
+ name = "1 vCPU, 1 GB RAM"
+ value = "s-1vcpu-1gb"
+ }
+ option {
+ name = "1 vCPU, 2 GB RAM"
+ value = "s-1vcpu-2gb"
+ }
+ option {
+ name = "2 vCPU, 2 GB RAM"
+ value = "s-2vcpu-2gb"
+ }
+ option {
+ name = "2 vCPU, 4 GB RAM"
+ value = "s-2vcpu-4gb"
+ }
+ option {
+ name = "4 vCPU, 8 GB RAM"
+ value = "s-4vcpu-8gb"
+ }
+ option {
+ name = "8 vCPU, 16 GB RAM"
+ value = "s-8vcpu-16gb"
}
}
-variable "home_volume_size" {
- type = number
- description = "How large would you like your home volume to be (in GB)?"
- default = 20
+
+data "coder_parameter" "home_volume_size" {
+ name = "How large would you like your home volume to be (in GB)?"
+ description = "This volume will be mounted to /home/coder."
+ type = "number"
+ default = "20"
+ mutable = false
validation {
- condition = var.home_volume_size >= 1
- error_message = "Value must be greater than or equal to 1."
+ min = 1
+ max = 999999
}
}
-variable "region" {
- type = string
- description = "Which region would you like to use?"
+data "coder_parameter" "region" {
+ name = "Which region would you like to use?"
+ description = "This is the region where your workspace will be created."
+ icon = "/emojis/1f30e.png"
+ type = "string"
default = "ams3"
- validation {
- condition = contains(["nyc1", "nyc2", "nyc3", "sfo1", "sfo2", "sfo3", "ams2", "ams3", "sgp1", "lon1", "fra1", "tor1", "blr1"], var.region)
- error_message = "Value must be nyc1, nyc2, nyc3, sfo1, sfo2, sfo3, ams2, ams3, sgp1, lon1, fra1, tor1 or blr1."
+ mutable = false
+ option {
+ name = "New York 1"
+ value = "nyc1"
+ icon = "/emojis/1f1fa-1f1f8.png"
+ }
+ option {
+ name = "New York 2"
+ value = "nyc2"
+ icon = "/emojis/1f1fa-1f1f8.png"
+ }
+ option {
+ name = "New York 3"
+ value = "nyc3"
+ icon = "/emojis/1f1fa-1f1f8.png"
+ }
+ option {
+ name = "San Francisco 1"
+ value = "sfo1"
+ icon = "/emojis/1f1fa-1f1f8.png"
+ }
+ option {
+ name = "San Francisco 2"
+ value = "sfo2"
+ icon = "/emojis/1f1fa-1f1f8.png"
+ }
+ option {
+ name = "San Francisco 3"
+ value = "sfo3"
+ icon = "/emojis/1f1fa-1f1f8.png"
+ }
+ option {
+ name = "Amsterdam 2"
+ value = "ams2"
+ icon = "/emojis/1f1f3-1f1f1.png"
+ }
+ option {
+ name = "Amsterdam 3"
+ value = "ams3"
+ icon = "/emojis/1f1f3-1f1f1.png"
+ }
+ option {
+ name = "Singapore 1"
+ value = "sgp1"
+ icon = "/emojis/1f1f8-1f1ec.png"
+ }
+ option {
+ name = "London 1"
+ value = "lon1"
+ icon = "/emojis/1f1ec-1f1e7.png"
+ }
+ option {
+ name = "Frankfurt 1"
+ value = "fra1"
+ icon = "/emojis/1f1e9-1f1ea.png"
+ }
+ option {
+ name = "Toronto 1"
+ value = "tor1"
+ icon = "/emojis/1f1e8-1f1e6.png"
+ }
+ option {
+ name = "Bangalore 1"
+ value = "blr1"
+ icon = "/emojis/1f1ee-1f1f3.png"
}
}
@@ -101,9 +243,9 @@ resource "coder_agent" "main" {
}
resource "digitalocean_volume" "home_volume" {
- region = var.region
+ region = data.coder_parameter.region.value
name = "coder-${data.coder_workspace.me.id}-home"
- size = var.home_volume_size
+ size = data.coder_parameter.home_volume_size.value
initial_filesystem_type = "ext4"
initial_filesystem_label = "coder-home"
# Protect the volume from being deleted due to changes in attributes.
@@ -113,11 +255,12 @@ resource "digitalocean_volume" "home_volume" {
}
resource "digitalocean_droplet" "workspace" {
- region = var.region
- count = data.coder_workspace.me.start_count
- name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
- image = var.droplet_image
- size = var.droplet_size
+ region = data.coder_parameter.region.value
+ count = data.coder_workspace.me.start_count
+ name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
+ image = data.coder_parameter.droplet_image.value
+ size = data.coder_parameter.droplet_size.value
+
volume_ids = [digitalocean_volume.home_volume.id]
user_data = templatefile("cloud-config.yaml.tftpl", {
username = data.coder_workspace.me.owner
@@ -161,5 +304,4 @@ resource "coder_metadata" "volume-info" {
key = "size"
value = "${digitalocean_volume.home_volume.size} GiB"
}
-
}
diff --git a/examples/templates/docker-code-server/main.tf b/examples/templates/docker-code-server/main.tf
index 0a31a785f42ee..b8284fe99011c 100644
--- a/examples/templates/docker-code-server/main.tf
+++ b/examples/templates/docker-code-server/main.tf
@@ -2,11 +2,11 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
docker = {
source = "kreuzwerker/docker"
- version = "~> 2.20.2"
+ version = "~> 3.0.1"
}
}
}
@@ -21,9 +21,8 @@ data "coder_workspace" "me" {
}
resource "coder_agent" "main" {
- arch = data.coder_provisioner.me.arch
- os = "linux"
-
+ arch = data.coder_provisioner.me.arch
+ os = "linux"
login_before_ready = false
startup_script_timeout = 180
startup_script = <<-EOT
diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf
index 8648d126dac3b..a660cd2c5bc7e 100644
--- a/examples/templates/docker-image-builds/main.tf
+++ b/examples/templates/docker-image-builds/main.tf
@@ -3,11 +3,11 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
docker = {
source = "kreuzwerker/docker"
- version = "~> 2.20.2"
+ version = "~> 3.0.1"
}
}
}
@@ -22,9 +22,8 @@ data "coder_workspace" "me" {
}
resource "coder_agent" "main" {
- arch = data.coder_provisioner.me.arch
- os = "linux"
-
+ arch = data.coder_provisioner.me.arch
+ os = "linux"
login_before_ready = false
startup_script_timeout = 180
startup_script = <<-EOT
@@ -50,24 +49,29 @@ resource "coder_app" "code-server" {
interval = 3
threshold = 10
}
-
}
-variable "docker_image" {
- description = "What Docker image would you like to use for your workspace?"
+data "coder_parameter" "docker_image" {
+ name = "What Docker image would you like to use for your workspace?"
+ description = "The Docker image will be used to build your workspace. You can choose from a list of pre-built images or provide your own."
default = "base"
-
- # List of images available for the user to choose from.
- # Delete this condition to give users free text input.
- validation {
- condition = contains(["base", "java", "node"], var.docker_image)
- error_message = "Invalid Docker image!"
- }
-
- # Prevents admin errors when the image is not found
- validation {
- condition = fileexists("images/${var.docker_image}.Dockerfile")
- error_message = "Invalid Docker image. The file does not exist in the images directory."
+ icon = "/icon/docker.png"
+ type = "string"
+ mutable = false
+ option {
+ name = "Base"
+ value = "base"
+ icon = "/icon/code.svg"
+ }
+ option {
+ name = "Java"
+ value = "java"
+ icon = "/icon/java.svg"
+ }
+ option {
+ name = "Node"
+ value = "node"
+ icon = "/icon/node.svg"
}
}
@@ -101,18 +105,17 @@ resource "docker_volume" "home_volume" {
resource "docker_image" "coder_image" {
name = "coder-base-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
build {
- path = "./images/"
- dockerfile = "${var.docker_image}.Dockerfile"
- tag = ["coder-${var.docker_image}:v0.1"]
+ context = "./images/"
+ dockerfile = "${data.coder_parameter.docker_image.value}.Dockerfile"
+ tag = ["coder-${data.coder_parameter.docker_image.value}:v0.1"]
}
-
# Keep alive for other workspaces to use upon deletion
keep_locally = true
}
resource "docker_container" "workspace" {
count = data.coder_workspace.me.start_count
- image = docker_image.coder_image.latest
+ image = docker_image.coder_image.image_id
# Uses lower() to avoid Docker restriction on container names.
name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
# Hostname makes the shell more user friendly: coder@my-workspace:~$
@@ -154,6 +157,6 @@ resource "coder_metadata" "container_info" {
item {
key = "image"
- value = var.docker_image
+ value = data.coder_parameter.docker_image.value
}
}
diff --git a/examples/templates/docker-with-dotfiles/main.tf b/examples/templates/docker-with-dotfiles/main.tf
index e0232f8b86858..5c655d704d779 100644
--- a/examples/templates/docker-with-dotfiles/main.tf
+++ b/examples/templates/docker-with-dotfiles/main.tf
@@ -9,11 +9,11 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
docker = {
source = "kreuzwerker/docker"
- version = "~> 2.20.2"
+ version = "~> 3.0.1"
}
}
}
@@ -27,26 +27,33 @@ provider "docker" {
data "coder_workspace" "me" {
}
-variable "docker_image" {
- default = "codercom/enterprise-base:ubuntu"
+data "coder_parameter" "docker_image" {
+ name = "What Docker image would you like to use for your workspace?"
+ description = "The Docker image will be used to build your workspace."
+ default = "codercom/enterprise-base:ubuntu"
+ icon = "/icon/docker.png"
+ type = "string"
+ mutable = false
}
-variable "dotfiles_uri" {
+data "coder_parameter" "dotfiles_uri" {
+ name = "What dotfiles repo would you like to use for your workspace?"
description = <<-EOF
Dotfiles repo URI (optional)
see https://dotfiles.github.io
EOF
default = ""
+ type = "string"
+ mutable = true
}
resource "coder_agent" "main" {
- arch = data.coder_provisioner.me.arch
- os = "linux"
-
+ arch = data.coder_provisioner.me.arch
+ os = "linux"
login_before_ready = false
startup_script_timeout = 180
- env = { "DOTFILES_URI" = var.dotfiles_uri != "" ? var.dotfiles_uri : null }
+ env = { "DOTFILES_URI" = data.coder_parameter.dotfiles_uri.value != "" ? data.coder_parameter.dotfiles_uri.value : null }
startup_script = <<-EOT
set -e
if [ -n "$DOTFILES_URI" ]; then
@@ -85,7 +92,7 @@ resource "docker_volume" "home_volume" {
resource "docker_container" "workspace" {
count = data.coder_workspace.me.start_count
- image = var.docker_image
+ image = data.coder_parameter.docker_image.value
# Uses lower() to avoid Docker restriction on container names.
name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
# Hostname makes the shell more user friendly: coder@my-workspace:~$
@@ -127,6 +134,6 @@ resource "coder_metadata" "container_info" {
item {
key = "image"
- value = var.docker_image
+ value = data.coder_parameter.docker_image.value
}
}
diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf
index f31333f226c68..6df6868f5a978 100644
--- a/examples/templates/docker/main.tf
+++ b/examples/templates/docker/main.tf
@@ -2,11 +2,11 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
docker = {
source = "kreuzwerker/docker"
- version = "~> 2.22"
+ version = "~> 3.0.1"
}
}
}
@@ -25,9 +25,8 @@ data "coder_workspace" "me" {
}
resource "coder_agent" "main" {
- arch = data.coder_provisioner.me.arch
- os = "linux"
-
+ arch = data.coder_provisioner.me.arch
+ os = "linux"
login_before_ready = false
startup_script_timeout = 180
startup_script = <<-EOT
@@ -66,7 +65,6 @@ resource "coder_app" "code-server" {
}
}
-
resource "docker_volume" "home_volume" {
name = "coder-${data.coder_workspace.me.id}-home"
# Protect the volume from being deleted due to changes in attributes.
@@ -94,11 +92,10 @@ resource "docker_volume" "home_volume" {
}
}
-
resource "docker_image" "main" {
name = "coder-${data.coder_workspace.me.id}"
build {
- path = "./build"
+ context = "./build"
build_args = {
USER = local.username
}
diff --git a/examples/templates/gcp-linux/main.tf b/examples/templates/gcp-linux/main.tf
index 0e017a3504013..41c8387a494fe 100644
--- a/examples/templates/gcp-linux/main.tf
+++ b/examples/templates/gcp-linux/main.tf
@@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
google = {
source = "hashicorp/google"
@@ -11,21 +11,49 @@ terraform {
}
}
+provider "coder" {
+ feature_use_managed_variables = true
+}
+
variable "project_id" {
description = "Which Google Compute Project should your workspace live in?"
}
-variable "zone" {
- description = "What region should your workspace live in?"
- default = "us-central1-a"
- validation {
- condition = contains(["northamerica-northeast1-a", "us-central1-a", "us-west2-c", "europe-west4-b", "southamerica-east1-a"], var.zone)
- error_message = "Invalid zone!"
+data "coder_parameter" "zone" {
+ name = "What region should your workspace live in?"
+ type = "string"
+ icon = "/emojis/1f30e.png"
+ default = "us-central1-a"
+ 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"
}
}
provider "google" {
- zone = var.zone
+ zone = data.coder_parameter.zone.value
project = var.project_id
}
@@ -38,7 +66,7 @@ data "coder_workspace" "me" {
resource "google_compute_disk" "root" {
name = "coder-${data.coder_workspace.me.id}-root"
type = "pd-ssd"
- zone = var.zone
+ zone = data.coder_parameter.zone.value
image = "debian-cloud/debian-11"
lifecycle {
ignore_changes = [name, image]
@@ -46,10 +74,9 @@ resource "google_compute_disk" "root" {
}
resource "coder_agent" "main" {
- auth = "google-instance-identity"
- arch = "amd64"
- os = "linux"
-
+ auth = "google-instance-identity"
+ arch = "amd64"
+ os = "linux"
login_before_ready = false
startup_script_timeout = 180
startup_script = <<-EOT
@@ -79,7 +106,7 @@ resource "coder_app" "code-server" {
}
resource "google_compute_instance" "dev" {
- zone = var.zone
+ zone = data.coder_parameter.zone.value
count = data.coder_workspace.me.start_count
name = "coder-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}-root"
machine_type = "e2-medium"
diff --git a/examples/templates/gcp-vm-container/main.tf b/examples/templates/gcp-vm-container/main.tf
index aa74f10c7fe20..447de56a1822d 100644
--- a/examples/templates/gcp-vm-container/main.tf
+++ b/examples/templates/gcp-vm-container/main.tf
@@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
google = {
source = "hashicorp/google"
@@ -11,21 +11,49 @@ terraform {
}
}
+provider "coder" {
+ feature_use_managed_variables = true
+}
+
variable "project_id" {
description = "Which Google Compute Project should your workspace live in?"
}
-variable "zone" {
- description = "What region should your workspace live in?"
- default = "us-central1-a"
- validation {
- condition = contains(["northamerica-northeast1-a", "us-central1-a", "us-west2-c", "europe-west4-b", "southamerica-east1-a"], var.zone)
- error_message = "Invalid zone!"
+data "coder_parameter" "zone" {
+ name = "What region 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"
}
}
provider "google" {
- zone = var.zone
+ zone = data.coder_parameter.zone.value
project = var.project_id
}
@@ -83,7 +111,7 @@ module "gce-container" {
}
resource "google_compute_instance" "dev" {
- zone = var.zone
+ zone = data.coder_parameter.zone.value
count = data.coder_workspace.me.start_count
name = "coder-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}"
machine_type = "e2-medium"
diff --git a/examples/templates/gcp-windows/main.tf b/examples/templates/gcp-windows/main.tf
index b8ff7e70e61fb..e57a7adb5732e 100644
--- a/examples/templates/gcp-windows/main.tf
+++ b/examples/templates/gcp-windows/main.tf
@@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
google = {
source = "hashicorp/google"
@@ -11,21 +11,49 @@ terraform {
}
}
+provider "coder" {
+ feature_use_managed_variables = true
+}
+
variable "project_id" {
description = "Which Google Compute Project should your workspace live in?"
}
-variable "zone" {
- description = "What region should your workspace live in?"
- default = "us-central1-a"
- validation {
- condition = contains(["northamerica-northeast1-a", "us-central1-a", "us-west2-c", "europe-west4-b", "southamerica-east1-a"], var.zone)
- error_message = "Invalid zone!"
+data "coder_parameter" "zone" {
+ name = "What region 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"
}
}
provider "google" {
- zone = var.zone
+ zone = data.coder_parameter.zone.value
project = var.project_id
}
@@ -38,7 +66,7 @@ data "google_compute_default_service_account" "default" {
resource "google_compute_disk" "root" {
name = "coder-${data.coder_workspace.me.id}-root"
type = "pd-ssd"
- zone = var.zone
+ zone = data.coder_parameter.zone.value
image = "projects/windows-cloud/global/images/windows-server-2022-dc-core-v20220215"
lifecycle {
ignore_changes = [name, image]
@@ -54,7 +82,7 @@ resource "coder_agent" "main" {
}
resource "google_compute_instance" "dev" {
- zone = var.zone
+ zone = data.coder_parameter.zone.value
count = data.coder_workspace.me.start_count
name = "coder-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}"
machine_type = "e2-medium"
diff --git a/examples/templates/kubernetes-with-podman/main.tf b/examples/templates/kubernetes-with-podman/main.tf
index 1211136a524de..01ea4f52adea6 100644
--- a/examples/templates/kubernetes-with-podman/main.tf
+++ b/examples/templates/kubernetes-with-podman/main.tf
@@ -2,11 +2,11 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
kubernetes = {
source = "hashicorp/kubernetes"
- version = "~> 2.10"
+ version = "~> 2.18"
}
}
}
@@ -17,40 +17,60 @@ provider "kubernetes" {
data "coder_workspace" "me" {}
-variable "os" {
- description = "Operating system"
- validation {
- condition = contains(["ubuntu", "fedora"], var.os)
- error_message = "Invalid zone!"
- }
+data "coder_parameter" "os" {
+ name = "Operating system"
default = "ubuntu"
+ option {
+ name = "Ubuntu"
+ value = "ubuntu"
+ icon = "/icon/ubuntu.svg"
+ }
+ option {
+ name = "Fedora"
+ value = "fedora"
+ icon = "/icon/fedora.svg"
+ }
}
-variable "cpu" {
- description = "CPU (__ cores)"
- default = 2
- validation {
- condition = contains([
- "2",
- "4",
- "6",
- "8"
- ], var.cpu)
- error_message = "Invalid cpu!"
+data "coder_parameter" "cpu" {
+ name = "CPU (cores)"
+ default = "2"
+ option {
+ name = "2 Cores"
+ value = "2"
+ }
+ option {
+ name = "4 Cores"
+ value = "4"
+ }
+ option {
+ name = "6 Cores"
+ value = "6"
+ }
+ option {
+ name = "8 Cores"
+ value = "8"
}
}
-variable "memory" {
- description = "Memory (__ GB)"
- default = 2
- validation {
- condition = contains([
- "2",
- "4",
- "6",
- "8"
- ], var.memory)
- error_message = "Invalid memory!"
+data "coder_parameter" "memory" {
+ name = "Memory (GB)"
+ default = "2"
+ option {
+ name = "2 GB"
+ value = "2"
+ }
+ option {
+ name = "4 GB"
+ value = "4"
+ }
+ option {
+ name = "6 GB"
+ value = "6"
+ }
+ option {
+ name = "8 GB"
+ value = "8"
}
}
@@ -72,10 +92,11 @@ resource "coder_agent" "dev" {
# code-server
resource "coder_app" "code-server" {
- agent_id = coder_agent.dev.id
- name = "code-server"
- icon = "/icon/code.svg"
- url = "http://localhost:13337"
+ agent_id = coder_agent.dev.id
+ display_name = "Code Server"
+ slug = "code-server"
+ icon = "/icon/code.svg"
+ url = "http://localhost:13337"
}
resource "kubernetes_pod" "main" {
@@ -100,7 +121,7 @@ resource "kubernetes_pod" "main" {
container {
name = "dev"
# We recommend building your own from our reference: see ./images directory
- image = "ghcr.io/coder/podman:${var.os}"
+ image = "ghcr.io/coder/podman:${data.coder_parameter.os.value}"
image_pull_policy = "Always"
command = ["/bin/bash", "-c", coder_agent.dev.init_script]
security_context {
@@ -115,8 +136,8 @@ resource "kubernetes_pod" "main" {
limits = {
# Acquire a FUSE device, powered by smarter-device-manager
"github.com/fuse" : 1
- cpu = "${var.cpu}"
- memory = "${var.memory}Gi"
+ cpu = "${data.coder_parameter.cpu.value}"
+ memory = "${data.coder_parameter.memory.value}Gi"
}
}
diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf
index 22e44f0dc5c2a..e1237fe8b384d 100644
--- a/examples/templates/kubernetes/main.tf
+++ b/examples/templates/kubernetes/main.tf
@@ -2,18 +2,21 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
- version = "~> 0.6.12"
+ version = "~> 0.6.17"
}
kubernetes = {
source = "hashicorp/kubernetes"
- version = "~> 2.12.1"
+ version = "~> 2.18"
}
}
}
+provider "coder" {
+ feature_use_managed_variables = true
+}
+
variable "use_kubeconfig" {
type = bool
- sensitive = true
description = <<-EOF
Use host kubeconfig? (true/false)
@@ -23,63 +26,82 @@ variable "use_kubeconfig" {
Set this to true if the Coder host is running outside the Kubernetes cluster
for workspaces. A valid "~/.kube/config" must be present on the Coder host.
EOF
+ default = false
}
variable "namespace" {
type = string
- sensitive = true
description = "The Kubernetes namespace to create workspaces in (must exist prior to creating workspaces)"
}
-variable "cpu" {
- description = "CPU (__ cores)"
- default = 2
- validation {
- condition = contains([
- "2",
- "4",
- "6",
- "8"
- ], var.cpu)
- error_message = "Invalid cpu!"
+data "coder_parameter" "cpu" {
+ name = "CPU (cores)"
+ default = "2"
+ icon = "/icon/memory.svg"
+ mutable = true
+ option {
+ name = "2 Cores"
+ value = "2"
+ }
+ option {
+ name = "4 Cores"
+ value = "4"
+ }
+ option {
+ name = "6 Cores"
+ value = "6"
+ }
+ option {
+ name = "8 Cores"
+ value = "8"
}
}
-variable "memory" {
- description = "Memory (__ GB)"
- default = 2
- validation {
- condition = contains([
- "2",
- "4",
- "6",
- "8"
- ], var.memory)
- error_message = "Invalid memory!"
+data "coder_parameter" "memory" {
+ name = "Memory (GB)"
+ default = "2"
+ icon = "/icon/memory.svg"
+ mutable = true
+ option {
+ name = "2 GB"
+ value = "2"
+ }
+ option {
+ name = "4 GB"
+ value = "4"
+ }
+ option {
+ name = "6 GB"
+ value = "6"
+ }
+ option {
+ name = "8 GB"
+ value = "8"
}
}
-variable "home_disk_size" {
- type = number
- description = "How large would you like your home volume to be (in GB)?"
- default = 10
+data "coder_parameter" "home_disk_size" {
+ name = "Home Disk Size (GB)"
+ default = "10"
+ type = "number"
+ icon = "/emojis/1f4be.png"
+ mutable = false
validation {
- condition = var.home_disk_size >= 1
- error_message = "Value must be greater than or equal to 1."
+ min = 1
+ max = 99999
}
}
provider "kubernetes" {
# Authenticate via ~/.kube/config or a Coder-specific ServiceAccount, depending on admin preferences
- config_path = var.use_kubeconfig == true ? "~/.kube/config" : null
+ config_path = var.namespace == true ? "~/.kube/config" : null
}
data "coder_workspace" "me" {}
resource "coder_agent" "main" {
- os = "linux"
- arch = "amd64"
-
+ os = "linux"
+ arch = "amd64"
login_before_ready = false
startup_script_timeout = 180
startup_script = <<-EOT
@@ -132,7 +154,7 @@ resource "kubernetes_persistent_volume_claim" "home" {
access_modes = ["ReadWriteOnce"]
resources {
requests = {
- storage = "${var.home_disk_size}Gi"
+ storage = "${data.coder_parameter.home_disk_size.value}Gi"
}
}
}
@@ -181,8 +203,8 @@ resource "kubernetes_pod" "main" {
"memory" = "512Mi"
}
limits = {
- "cpu" = "${var.cpu}"
- "memory" = "${var.memory}Gi"
+ "cpu" = "${data.coder_parameter.cpu.value}"
+ "memory" = "${data.coder_parameter.memory.value}Gi"
}
}
volume_mount {
diff --git a/site/static/icon/centos.svg b/site/static/icon/centos.svg
new file mode 100644
index 0000000000000..966fe3764b6bf
--- /dev/null
+++ b/site/static/icon/centos.svg
@@ -0,0 +1,214 @@
+
+
+
+
diff --git a/site/static/icon/debian.svg b/site/static/icon/debian.svg
new file mode 100644
index 0000000000000..99f210168ae42
--- /dev/null
+++ b/site/static/icon/debian.svg
@@ -0,0 +1,8 @@
+
+
\ No newline at end of file
diff --git a/site/static/icon/fedora.svg b/site/static/icon/fedora.svg
new file mode 100644
index 0000000000000..40668e211b302
--- /dev/null
+++ b/site/static/icon/fedora.svg
@@ -0,0 +1,36 @@
+
+
\ No newline at end of file
diff --git a/site/static/icon/java.svg b/site/static/icon/java.svg
new file mode 100644
index 0000000000000..91e4133071ef0
--- /dev/null
+++ b/site/static/icon/java.svg
@@ -0,0 +1,41 @@
+
+
+
+
diff --git a/site/static/icon/node.svg b/site/static/icon/node.svg
new file mode 100644
index 0000000000000..41d044ac6b3f4
--- /dev/null
+++ b/site/static/icon/node.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/static/icon/rockylinux.svg b/site/static/icon/rockylinux.svg
new file mode 100644
index 0000000000000..58f22104e3603
--- /dev/null
+++ b/site/static/icon/rockylinux.svg
@@ -0,0 +1,3 @@
+
diff --git a/site/static/icon/ubuntu.svg b/site/static/icon/ubuntu.svg
new file mode 100644
index 0000000000000..f217bc8d5dbf6
--- /dev/null
+++ b/site/static/icon/ubuntu.svg
@@ -0,0 +1,8 @@
+
\ No newline at end of file