From 986423a690e22fe4f6268a56a7d1bfae0a3a126f Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 1 Mar 2023 16:49:45 +0300 Subject: [PATCH 01/32] update templates to use rich parameters --- examples/templates/aws-ecs-container/main.tf | 3 +- examples/templates/do-linux/main.tf | 211 ++++++++++++++---- examples/templates/docker-code-server/main.tf | 4 +- .../templates/docker-image-builds/main.tf | 43 ++-- .../templates/docker-with-dotfiles/main.tf | 4 +- examples/templates/docker/main.tf | 4 +- examples/templates/gcp-linux/main.tf | 55 +++-- examples/templates/gcp-vm-container/main.tf | 54 +++-- examples/templates/gcp-windows/main.tf | 51 +++-- .../templates/kubernetes-with-podman/main.tf | 85 ++++--- examples/templates/kubernetes/main.tf | 103 +++++---- 11 files changed, 432 insertions(+), 185 deletions(-) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index ce30acd39037e..771c9a01b7561 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.14" } aws = { source = "hashicorp/aws" @@ -15,6 +15,7 @@ variable "ecs-cluster" { description = "Input the ECS cluster ARN to host the workspace" default = "" } + variable "cpu" { default = "1024" } diff --git a/examples/templates/do-linux/main.tf b/examples/templates/do-linux/main.tf index edf31448b2b57..3c9529ec31bde 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.14" } digitalocean = { source = "digitalocean/digitalocean" @@ -11,77 +11,205 @@ terraform { } } -variable "step1_do_project_id" { - type = string + + +data "coder_parameter" "step1_do_project_id" { + name = "Enter project ID" description = <<-EOF Enter project ID $ doctl projects list EOF - sensitive = true - + type = "string" + default = "0" + mutable = false validation { - condition = length(var.step1_do_project_id) == 36 - error_message = "Invalid Digital Ocean Project ID." + # make sure length of alphanumeric string is 36 + regex = "^[a-zA-Z0-9]{36}$" + error = "Invalid Digital Ocean Project ID." } } -variable "step2_do_admin_ssh_key" { - type = number +data "coder_parameter" "step2_do_admin_ssh_key" { + name = "Enter admin SSH key ID (some Droplet images require an SSH key to be set):" description = <<-EOF - Enter admin SSH key ID (some Droplet images require an SSH key to be set): - Can be set to "0" for no key. Note: Setting this to zero will break Fedora images and notify root passwords via email. $ doctl compute ssh-key list EOF - sensitive = true - + type = "number" + default = "0" + mutable = false validation { - condition = var.step2_do_admin_ssh_key >= 0 - error_message = "Invalid Digital Ocean SSH key ID, a number is required." + min = 0 + error = "Invalid Digital Ocean SSH key ID, a number is required." } } -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" + } + option { + name = "Ubuntu 20.04" + value = "ubuntu-20-04-x64" + } + option { + name = "Fedora 36" + value = "fedora-36-x64" + } + option { + name = "Fedora 35" + value = "fedora-35-x64" + } + option { + name = "Debian 11" + value = "debian-11-x64" + } + option { + name = "Debian 10" + value = "debian-10-x64" + } + option { + name = "CentOS Stream 9" + value = "centos-stream-9-x64" + } + option { + name = "CentOS Stream 8" + value = "centos-stream-8-x64" + } + option { + name = "Rocky Linux 8" + value = "rockylinux-8-x64" + } + option { + name = "Rocky Linux 8.4" + value = "rockylinux-8-4-x64" } } -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" + mutable = false + option { + name = "s-1vcpu-1gb" + value = "s-1vcpu-1gb" + } + option { + name = "s-1vcpu-2gb" + value = "s-1vcpu-2gb" + } + option { + name = "s-2vcpu-2gb" + value = "s-2vcpu-2gb" + } + option { + name = "s-2vcpu-4gb" + value = "s-2vcpu-4gb" + } + option { + name = "s-4vcpu-8gb" + value = "s-4vcpu-8gb" + } + option { + name = "s-8vcpu-16gb" + 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 + error = "Value must be greater than or equal to 1." } } -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" } } @@ -161,5 +289,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..a18c8c08cebac 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.14" } docker = { source = "kreuzwerker/docker" - version = "~> 2.20.2" + version = "~> 3.0.1" } } } diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf index 8648d126dac3b..aa02a442bd8a5 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.14" } docker = { source = "kreuzwerker/docker" - version = "~> 2.20.2" + version = "~> 3.0.1" } } } @@ -53,24 +53,31 @@ resource "coder_app" "code-server" { } -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 = "/emojis/1f4bf.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" } } + resource "docker_volume" "home_volume" { name = "coder-${data.coder_workspace.me.id}-home" # Protect the volume from being deleted due to changes in attributes. @@ -102,7 +109,7 @@ 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" + dockerfile = "${data.coder_parameter.docker_image.value}.Dockerfile" tag = ["coder-${var.docker_image}:v0.1"] } @@ -154,6 +161,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..24ed5bf9f0d32 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.14" } docker = { source = "kreuzwerker/docker" - version = "~> 2.20.2" + version = "~> 3.0.1" } } } diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf index f31333f226c68..be66dc3cc08c7 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.14" } docker = { source = "kreuzwerker/docker" - version = "~> 2.22" + version = "~> 3.0.1" } } } diff --git a/examples/templates/gcp-linux/main.tf b/examples/templates/gcp-linux/main.tf index 0e017a3504013..a4d29d93d6709 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.14" } google = { source = "hashicorp/google" @@ -11,34 +11,59 @@ terraform { } } -variable "project_id" { - description = "Which Google Compute Project should your workspace live in?" +data "coder_parameter" "project_id" { + name = "What Google Compute Project should your workspace live in?" + description = "The Google Compute Project will be used to build your workspace." + type = "string" } -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" + 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 - project = var.project_id + zone = data.coder_parameter.zone.value + project = data.coder_parameter.project_id.value } -data "google_compute_default_service_account" "default" { +data "coder_workspace" "me" { } -data "coder_workspace" "me" { +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 = "debian-cloud/debian-11" lifecycle { ignore_changes = [name, image] @@ -79,7 +104,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..b2db148fca740 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.14" } google = { source = "hashicorp/google" @@ -11,30 +11,56 @@ terraform { } } -variable "project_id" { - description = "Which Google Compute Project should your workspace live in?" +data "coder_parameter" "project_id" { + name = "What Google Compute Project should your workspace live in?" + description = "The Google Compute Project will be used to build your workspace." + type = "string" } -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" + 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 - project = var.project_id + zone = data.coder_parameter.zone.value + project = data.coder_parameter.project_id.value } -data "google_compute_default_service_account" "default" { +data "coder_workspace" "me" { } -data "coder_workspace" "me" { +data "google_compute_default_service_account" "default" { } + resource "coder_agent" "main" { auth = "google-instance-identity" arch = "amd64" @@ -83,7 +109,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..7e206e96e380e 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.14" } google = { source = "hashicorp/google" @@ -11,22 +11,47 @@ terraform { } } -variable "project_id" { - description = "Which Google Compute Project should your workspace live in?" +data "coder_parameter" "project_id" { + name = "What Google Compute Project should your workspace live in?" + description = "The Google Compute Project will be used to build your workspace." + type = "string" } -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" + 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 - project = var.project_id + zone = data.coder_parameter.zone.value + project = data.coder_parameter.project_id.value } data "coder_workspace" "me" { @@ -38,7 +63,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 +79,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..04b7b212aa9e8 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.14" } kubernetes = { source = "hashicorp/kubernetes" - version = "~> 2.10" + version = "~> 2.12" } } } @@ -17,43 +17,62 @@ 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" + } + option { + name = "Fedora" + value = "fedora" + } } -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" + value = "2" + } + option { + name = "4" + value = "4" + } + option { + name = "6" + value = "6" + } + option { + name = "8" + 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" + value = "2" + } + option { + name = "4" + value = "4" + } + option { + name = "6" + value = "6" + } + option { + name = "8" + value = "8" } } + resource "coder_agent" "dev" { os = "linux" arch = "amd64" @@ -100,7 +119,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 +134,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..ddbf52bef9188 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -2,18 +2,17 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.12" + version = "~> 0.6.14" } kubernetes = { source = "hashicorp/kubernetes" - version = "~> 2.12.1" + version = "~> 2.12" } } } -variable "use_kubeconfig" { - type = bool - sensitive = true +data "coder_parameter" "use_kubeconfig" { + name = "Use host kubeconfig? (true/false)" description = <<-EOF Use host kubeconfig? (true/false) @@ -23,55 +22,73 @@ 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 + type = "bool" + default = "false" + mutable = false } -variable "namespace" { - type = string - sensitive = true - description = "The Kubernetes namespace to create workspaces in (must exist prior to creating workspaces)" +data "coder_parameter" "namespace" { + name = "The Kubernetes namespace to create workspaces in (must exist prior to creating workspaces)" + mutable = false } -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 = + mutable = true + option { + name = "2" + value = "2" + } + option { + name = "4" + value = "4" + } + option { + name = "6" + value = "6" + } + option { + name = "8" + 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" + mutable = true + option { + name = "2" + value = "2" + } + option { + name = "4" + value = "4" + } + option { + name = "6" + value = "6" + } + option { + name = "8" + 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" + mutable = false validation { - condition = var.home_disk_size >= 1 - error_message = "Value must be greater than or equal to 1." + min = 1 } } 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 = "data.coder_parameter.use_kubeconfig.value" == "true" ? "~/.kube/config" : null } data "coder_workspace" "me" {} @@ -111,7 +128,7 @@ resource "coder_app" "code-server" { resource "kubernetes_persistent_volume_claim" "home" { metadata { name = "coder-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}-home" - namespace = var.namespace + namespace = data.coder_parameter.namespace.value labels = { "app.kubernetes.io/name" = "coder-pvc" "app.kubernetes.io/instance" = "coder-pvc-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}" @@ -132,7 +149,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" } } } @@ -142,7 +159,7 @@ resource "kubernetes_pod" "main" { count = data.coder_workspace.me.start_count metadata { name = "coder-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}" - namespace = var.namespace + namespace = data.coder_parameter.namespace.value labels = { "app.kubernetes.io/name" = "coder-workspace" "app.kubernetes.io/instance" = "coder-workspace-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}" @@ -181,8 +198,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 { From aed5f6ccc4239f27d4f1cd1f5408396535f570a1 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 1 Mar 2023 17:01:09 +0300 Subject: [PATCH 02/32] more icons --- examples/templates/kubernetes/main.tf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf index ddbf52bef9188..d645bb68a3812 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -35,7 +35,7 @@ data "coder_parameter" "namespace" { data "coder_parameter" "cpu" { name = "CPU (cores)" default = "2" - icon = + icon = "/icon/memory.svg" mutable = true option { name = "2" @@ -58,6 +58,7 @@ data "coder_parameter" "cpu" { data "coder_parameter" "memory" { name = "Memory (GB)" default = "2" + icon = "/icon/memory.svg" mutable = true option { name = "2" @@ -80,6 +81,7 @@ data "coder_parameter" "memory" { data "coder_parameter" "home_disk_size" { name = "Home Disk Size (GB)" default = "10" + icon = "/emojis/1f4be.png" mutable = false validation { min = 1 From abec445d87879cc94bb4bc8dbcfb646ff78bb9a5 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 1 Mar 2023 17:12:08 +0300 Subject: [PATCH 03/32] fix do-linux --- examples/templates/do-linux/main.tf | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/examples/templates/do-linux/main.tf b/examples/templates/do-linux/main.tf index 3c9529ec31bde..d5ef3cb6050ea 100644 --- a/examples/templates/do-linux/main.tf +++ b/examples/templates/do-linux/main.tf @@ -43,8 +43,8 @@ data "coder_parameter" "step2_do_admin_ssh_key" { default = "0" mutable = false validation { - min = 0 - error = "Invalid Digital Ocean SSH key ID, a number is required." + min = 0 + max = 999999 } } @@ -134,8 +134,8 @@ data "coder_parameter" "home_volume_size" { default = "20" mutable = false validation { - min = 1 - error = "Value must be greater than or equal to 1." + min = 1 + max = 999999 } } @@ -229,9 +229,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. @@ -241,11 +241,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 @@ -254,11 +255,11 @@ resource "digitalocean_droplet" "workspace" { coder_agent_token = coder_agent.main.token }) # Required to provision Fedora. - ssh_keys = var.step2_do_admin_ssh_key > 0 ? [var.step2_do_admin_ssh_key] : [] + ssh_keys = data.coder_parameter.step1_do_project_id.value > 0 ? [data.coder_parameter.step2_do_admin_ssh_key.value] : [] } resource "digitalocean_project_resources" "project" { - project = var.step1_do_project_id + project = data.coder_parameter.step1_do_project_id.value # Workaround for terraform plan when using count. resources = length(digitalocean_droplet.workspace) > 0 ? [ digitalocean_volume.home_volume.urn, From 2f17c1d26187457dcbc317b03e7b2f3dd6926a50 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 1 Mar 2023 17:19:32 +0300 Subject: [PATCH 04/32] fix: docker-image-builds --- examples/templates/docker-image-builds/main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf index aa02a442bd8a5..3b16d8f3d7c14 100644 --- a/examples/templates/docker-image-builds/main.tf +++ b/examples/templates/docker-image-builds/main.tf @@ -108,9 +108,9 @@ 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/" + context = "./images/" dockerfile = "${data.coder_parameter.docker_image.value}.Dockerfile" - tag = ["coder-${var.docker_image}:v0.1"] + tag = ["coder-${data.coder_parameter.docker_image.value}:v0.1"] } # Keep alive for other workspaces to use upon deletion @@ -119,7 +119,7 @@ resource "docker_image" "coder_image" { 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:~$ From 31824c37d7469a60c54d8859f622573b873a7ce9 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 1 Mar 2023 17:29:01 +0300 Subject: [PATCH 05/32] fix kubernetes --- .../templates/kubernetes-with-podman/main.tf | 27 +++++++------- examples/templates/kubernetes/main.tf | 17 ++++----- site/static/icon/fedora.svg | 36 +++++++++++++++++++ site/static/icon/ubuntu.svg | 8 +++++ 4 files changed, 68 insertions(+), 20 deletions(-) create mode 100644 site/static/icon/fedora.svg create mode 100644 site/static/icon/ubuntu.svg diff --git a/examples/templates/kubernetes-with-podman/main.tf b/examples/templates/kubernetes-with-podman/main.tf index 04b7b212aa9e8..2df7efe83c5a3 100644 --- a/examples/templates/kubernetes-with-podman/main.tf +++ b/examples/templates/kubernetes-with-podman/main.tf @@ -23,10 +23,12 @@ data "coder_parameter" "os" { option { name = "Ubuntu" value = "ubuntu" + icon = "/icon/ubuntu.svg" } option { name = "Fedora" value = "fedora" + icon = "/icon/fedora.svg" } } @@ -34,19 +36,19 @@ data "coder_parameter" "cpu" { name = "CPU (cores)" default = "2" option { - name = "2" + name = "2 Cores" value = "2" } option { - name = "4" + name = "4 Cores" value = "4" } option { - name = "6" + name = "6 Cores" value = "6" } option { - name = "8" + name = "8 Cores" value = "8" } } @@ -55,19 +57,19 @@ data "coder_parameter" "memory" { name = "Memory (GB)" default = "2" option { - name = "2" + name = "2 GB" value = "2" } option { - name = "4" + name = "4 GB" value = "4" } option { - name = "6" + name = "6 GB" value = "6" } option { - name = "8" + name = "8 GB" value = "8" } } @@ -91,10 +93,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" { diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf index d645bb68a3812..7c866a6e729c2 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -38,19 +38,19 @@ data "coder_parameter" "cpu" { icon = "/icon/memory.svg" mutable = true option { - name = "2" + name = "2 Cores" value = "2" } option { - name = "4" + name = "4 Cores" value = "4" } option { - name = "6" + name = "6 Cores" value = "6" } option { - name = "8" + name = "8 Cores" value = "8" } } @@ -61,19 +61,19 @@ data "coder_parameter" "memory" { icon = "/icon/memory.svg" mutable = true option { - name = "2" + name = "2 GB" value = "2" } option { - name = "4" + name = "4 GB" value = "4" } option { - name = "6" + name = "6 GB" value = "6" } option { - name = "8" + name = "8 GB" value = "8" } } @@ -85,6 +85,7 @@ data "coder_parameter" "home_disk_size" { mutable = false validation { min = 1 + max = 99999 } } 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/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 From d0ab600a96bf9f4ae1be16220ee37c44e2521900 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 1 Mar 2023 17:34:00 +0300 Subject: [PATCH 06/32] add friendly names to do-linux --- examples/templates/do-linux/main.tf | 23 ++- site/static/icon/centos.svg | 214 ++++++++++++++++++++++++++++ site/static/icon/debian.svg | 8 ++ site/static/icon/rockylinux.svg | 3 + 4 files changed, 242 insertions(+), 6 deletions(-) create mode 100644 site/static/icon/centos.svg create mode 100644 site/static/icon/debian.svg create mode 100644 site/static/icon/rockylinux.svg diff --git a/examples/templates/do-linux/main.tf b/examples/templates/do-linux/main.tf index d5ef3cb6050ea..5226949d9f5c4 100644 --- a/examples/templates/do-linux/main.tf +++ b/examples/templates/do-linux/main.tf @@ -56,42 +56,52 @@ data "coder_parameter" "droplet_image" { 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" } } @@ -99,29 +109,30 @@ 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 = "s-1vcpu-1gb" + name = "1 core / 1 GB RAM" value = "s-1vcpu-1gb" } option { - name = "s-1vcpu-2gb" + name = "1 core / 2 GB RAM" value = "s-1vcpu-2gb" } option { - name = "s-2vcpu-2gb" + name = "2 cores / 2 GB RAM" value = "s-2vcpu-2gb" } option { - name = "s-2vcpu-4gb" + name = "2 cores / 4 GB RAM" value = "s-2vcpu-4gb" } option { - name = "s-4vcpu-8gb" + name = "4 cores / 8 GB RAM" value = "s-4vcpu-8gb" } option { - name = "s-8vcpu-16gb" + name = "8 cores / 16 GB RAM" value = "s-8vcpu-16gb" } } 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 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + 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/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 @@ + + + From 59b18d18aaed5d8f312b9460a991a108f5e22be0 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 07:29:59 +0300 Subject: [PATCH 07/32] use managed variables for do-linux --- examples/templates/do-linux/main.tf | 35 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/examples/templates/do-linux/main.tf b/examples/templates/do-linux/main.tf index 5226949d9f5c4..8a663c37ca4ae 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.14" + version = "~> 0.6.17" } digitalocean = { source = "digitalocean/digitalocean" @@ -11,41 +11,44 @@ terraform { } } +provider "coder" { + feature_use_managed_variables = true +} - -data "coder_parameter" "step1_do_project_id" { - name = "Enter project ID" +variable "step1_do_project_id" { + type = string description = <<-EOF Enter project ID $ doctl projects list EOF - type = "string" default = "0" - mutable = false validation { # make sure length of alphanumeric string is 36 - regex = "^[a-zA-Z0-9]{36}$" - error = "Invalid Digital Ocean Project ID." + condition = length(var.step1_do_project_id) == 36 + error_message = "Invalid Digital Ocean Project ID." } + } -data "coder_parameter" "step2_do_admin_ssh_key" { - name = "Enter admin SSH key ID (some Droplet images require an SSH key to be set):" +variable "step2_do_admin_ssh_key" { + type = string description = <<-EOF + Enter admin SSH key ID (some Droplet images require an SSH key to be set): + Can be set to "0" for no key. Note: Setting this to zero will break Fedora images and notify root passwords via email. $ doctl compute ssh-key list EOF - type = "number" default = "0" - mutable = false validation { - min = 0 - max = 999999 + # make sure value is a number + condition = can(regex("^[0-9]+$", var.step2_do_admin_ssh_key)) + error_message = "Invalid Digital Ocean SSH Key ID." } + } data "coder_parameter" "droplet_image" { @@ -266,11 +269,11 @@ resource "digitalocean_droplet" "workspace" { coder_agent_token = coder_agent.main.token }) # Required to provision Fedora. - ssh_keys = data.coder_parameter.step1_do_project_id.value > 0 ? [data.coder_parameter.step2_do_admin_ssh_key.value] : [] + ssh_keys = var.step1_do_project_id > 0 ? [var.step2_do_admin_ssh_key] : [] } resource "digitalocean_project_resources" "project" { - project = data.coder_parameter.step1_do_project_id.value + project = var.step1_do_project_id # Workaround for terraform plan when using count. resources = length(digitalocean_droplet.workspace) > 0 ? [ digitalocean_volume.home_volume.urn, From a84db0bf10f0ff45fe0cf71e4d07b5c8d2a337b3 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 07:38:07 +0300 Subject: [PATCH 08/32] update docker examples --- examples/templates/docker-code-server/main.tf | 7 +++--- .../templates/docker-image-builds/main.tf | 10 +++----- .../templates/docker-with-dotfiles/main.tf | 25 ++++++++++++------- examples/templates/docker/main.tf | 9 +++---- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/examples/templates/docker-code-server/main.tf b/examples/templates/docker-code-server/main.tf index a18c8c08cebac..b8284fe99011c 100644 --- a/examples/templates/docker-code-server/main.tf +++ b/examples/templates/docker-code-server/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.14" + version = "~> 0.6.17" } docker = { source = "kreuzwerker/docker" @@ -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 3b16d8f3d7c14..1c5cc16692e17 100644 --- a/examples/templates/docker-image-builds/main.tf +++ b/examples/templates/docker-image-builds/main.tf @@ -3,7 +3,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.14" + version = "~> 0.6.17" } docker = { source = "kreuzwerker/docker" @@ -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,7 +49,6 @@ resource "coder_app" "code-server" { interval = 3 threshold = 10 } - } data "coder_parameter" "docker_image" { @@ -77,7 +75,6 @@ data "coder_parameter" "docker_image" { } } - resource "docker_volume" "home_volume" { name = "coder-${data.coder_workspace.me.id}-home" # Protect the volume from being deleted due to changes in attributes. @@ -112,7 +109,6 @@ resource "docker_image" "coder_image" { 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 } diff --git a/examples/templates/docker-with-dotfiles/main.tf b/examples/templates/docker-with-dotfiles/main.tf index 24ed5bf9f0d32..6f9736c41a416 100644 --- a/examples/templates/docker-with-dotfiles/main.tf +++ b/examples/templates/docker-with-dotfiles/main.tf @@ -9,7 +9,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.14" + version = "~> 0.6.17" } docker = { source = "kreuzwerker/docker" @@ -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 = true } -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:~$ diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf index be66dc3cc08c7..6090af06df962 100644 --- a/examples/templates/docker/main.tf +++ b/examples/templates/docker/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.14" + version = "~> 0.6.17" } docker = { source = "kreuzwerker/docker" @@ -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,7 +92,6 @@ resource "docker_volume" "home_volume" { } } - resource "docker_image" "main" { name = "coder-${data.coder_workspace.me.id}" build { From 4caa9ea672d5903ce1318c91233d06dd76338c21 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 07:46:46 +0300 Subject: [PATCH 09/32] update gcp --- examples/templates/gcp-linux/main.tf | 21 ++++++++++++--------- examples/templates/gcp-vm-container/main.tf | 15 +++++++++------ examples/templates/gcp-windows/main.tf | 14 +++++++++----- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/examples/templates/gcp-linux/main.tf b/examples/templates/gcp-linux/main.tf index a4d29d93d6709..4b1d04d08e86f 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.14" + version = "~> 0.6.17" } google = { source = "hashicorp/google" @@ -11,10 +11,14 @@ terraform { } } -data "coder_parameter" "project_id" { - name = "What Google Compute Project should your workspace live in?" +provider "coder" { + feature_use_managed_variables = true +} + +variable "project_id" { + type = string description = "The Google Compute Project will be used to build your workspace." - type = "string" + default = "" } data "coder_parameter" "zone" { @@ -51,7 +55,7 @@ data "coder_parameter" "zone" { provider "google" { zone = data.coder_parameter.zone.value - project = data.coder_parameter.project_id.value + project = var.project_id } data "coder_workspace" "me" { @@ -71,10 +75,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 diff --git a/examples/templates/gcp-vm-container/main.tf b/examples/templates/gcp-vm-container/main.tf index b2db148fca740..39da3542e10fc 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.14" + version = "~> 0.6.17" } google = { source = "hashicorp/google" @@ -11,10 +11,14 @@ terraform { } } -data "coder_parameter" "project_id" { - name = "What Google Compute Project should your workspace live in?" +provider "coder" { + feature_use_managed_variables = true +} + +variable "project_id" { + type = string description = "The Google Compute Project will be used to build your workspace." - type = "string" + default = "" } data "coder_parameter" "zone" { @@ -51,7 +55,7 @@ data "coder_parameter" "zone" { provider "google" { zone = data.coder_parameter.zone.value - project = data.coder_parameter.project_id.value + project = var.project_id } data "coder_workspace" "me" { @@ -60,7 +64,6 @@ data "coder_workspace" "me" { data "google_compute_default_service_account" "default" { } - resource "coder_agent" "main" { auth = "google-instance-identity" arch = "amd64" diff --git a/examples/templates/gcp-windows/main.tf b/examples/templates/gcp-windows/main.tf index 7e206e96e380e..a6219c06a348e 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.14" + version = "~> 0.6.17" } google = { source = "hashicorp/google" @@ -11,10 +11,14 @@ terraform { } } -data "coder_parameter" "project_id" { - name = "What Google Compute Project should your workspace live in?" +provider "coder" { + feature_use_managed_variables = true +} + +variable "project_id" { + type = string description = "The Google Compute Project will be used to build your workspace." - type = "string" + default = "" } data "coder_parameter" "zone" { @@ -51,7 +55,7 @@ data "coder_parameter" "zone" { provider "google" { zone = data.coder_parameter.zone.value - project = data.coder_parameter.project_id.value + project = var.project_id } data "coder_workspace" "me" { From 3c3c0ef3311b86d03588aff6efe14679e81b0dea Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 07:54:11 +0300 Subject: [PATCH 10/32] update kubernetes --- .../templates/kubernetes-with-podman/main.tf | 5 ++- examples/templates/kubernetes/main.tf | 33 ++++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/examples/templates/kubernetes-with-podman/main.tf b/examples/templates/kubernetes-with-podman/main.tf index 2df7efe83c5a3..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.14" + version = "~> 0.6.17" } kubernetes = { source = "hashicorp/kubernetes" - version = "~> 2.12" + version = "~> 2.18" } } } @@ -74,7 +74,6 @@ data "coder_parameter" "memory" { } } - resource "coder_agent" "dev" { os = "linux" arch = "amd64" diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf index 7c866a6e729c2..49f6eca1197d5 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -2,17 +2,21 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.14" + version = "~> 0.6.17" } kubernetes = { source = "hashicorp/kubernetes" - version = "~> 2.12" + version = "~> 2.18" } } } -data "coder_parameter" "use_kubeconfig" { - name = "Use host kubeconfig? (true/false)" +provider "coder" { + feature_use_managed_variables = true +} + +variable "use_kubeconfig" { + type = bool description = <<-EOF Use host kubeconfig? (true/false) @@ -22,14 +26,12 @@ data "coder_parameter" "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 - type = "bool" - default = "false" - mutable = false + default = false } -data "coder_parameter" "namespace" { - name = "The Kubernetes namespace to create workspaces in (must exist prior to creating workspaces)" - mutable = false +variable "namespace" { + type = string + description = "The Kubernetes namespace to create workspaces in (must exist prior to creating workspaces)" } data "coder_parameter" "cpu" { @@ -91,15 +93,14 @@ data "coder_parameter" "home_disk_size" { provider "kubernetes" { # Authenticate via ~/.kube/config or a Coder-specific ServiceAccount, depending on admin preferences - config_path = "data.coder_parameter.use_kubeconfig.value" == "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 @@ -131,7 +132,7 @@ resource "coder_app" "code-server" { resource "kubernetes_persistent_volume_claim" "home" { metadata { name = "coder-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}-home" - namespace = data.coder_parameter.namespace.value + namespace = var.namespace labels = { "app.kubernetes.io/name" = "coder-pvc" "app.kubernetes.io/instance" = "coder-pvc-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}" @@ -162,7 +163,7 @@ resource "kubernetes_pod" "main" { count = data.coder_workspace.me.start_count metadata { name = "coder-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}" - namespace = data.coder_parameter.namespace.value + namespace = var.namespace labels = { "app.kubernetes.io/name" = "coder-workspace" "app.kubernetes.io/instance" = "coder-workspace-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}" From ad0f4542a54b4541e7e739f49d290cd72900723a Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 08:11:54 +0300 Subject: [PATCH 11/32] update azure-vm --- examples/templates/azure-linux/main.tf | 231 ++++++++++++++++++------- 1 file changed, 171 insertions(+), 60 deletions(-) diff --git a/examples/templates/azure-linux/main.tf b/examples/templates/azure-linux/main.tf index b5a3ae04c827b..e4aaea32f4019 100644 --- a/examples/templates/azure-linux/main.tf +++ b/examples/templates/azure-linux/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { coder = { source = "coder/coder" - version = "~> 0.6.12" + version = "~> 0.6.17" } azurerm = { source = "hashicorp/azurerm" @@ -11,64 +11,176 @@ terraform { } } -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/" + mutable = false + option { + name = "East US" + value = "eastus" + icon = "/emojis/1f1fa-1f1f8.png" + } + option { + name = "South Central US" + value = "southcentralus" + icon = "/emojis/1f1fa-1f1f8.png" + } + option { + name = "West US 2" + value = "westus2" + icon = "/emojis/1f1fa-1f1f8.png" + } + option { + name = "Australia East" + value = "australiaeast" + icon = "/emojis/1f1e6-1f1fa.png" + } + option { + name = "Southeast Asia" + value = "southeastasia" + icon = "/emojis/1f1f8-1f1e6.png" + } + option { + name = "North Europe" + value = "northeurope" + icon = "/emojis/1f1f3-1f1ea.png" + } + option { + name = "West Europe" + value = "westeurope" + icon = "/emojis/1f1f3-1f1ea.png" + } + option { + name = "Central India" + value = "centralindia" + icon = "/emojis/1f1ee-1f1f3.png" + } + option { + name = "East Asia" + value = "eastasia" + icon = "/emojis/1f1f0-1f1f7.png" + } + option { + name = "Japan East" + value = "japaneast" + icon = "/emojis/1f1ef-1f1f5.png" + } + option { + name = "Brazil South" + value = "brazilsouth" + icon = "/emojis/1f1e7-1f1f7.png" + } + option { + name = "Asia" + value = "asia" + icon = "/emojis/1f1f0-1f1f7.png" + } + option { + name = "Asia Pacific" + value = "asiapacific" + icon = "/emojis/1f1f0-1f1f7.png" + } + option { + name = "Australia" + value = "australia" + icon = "/emojis/1f1e6-1f1fa.png" + } + option { + name = "Brazil" + value = "brazil" + icon = "/emojis/1f1e7-1f1f7.png" + } + option { + name = "India" + value = "india" + icon = "/emojis/1f1ee-1f1f3.png" + } + option { + name = "Japan" + value = "japan" + icon = "/emojis/1f1ef-1f1f5.png" + } + option { + name = "South Africa" + value = "southafrica" + icon = "/emojis/1f1ff-1f1e6.png" + } + option { + name = "Switzerland" + value = "switzerland" + icon = "/emojis/1f1e8-1f1ed.png" + } + option { + name = "UAE" + value = "uae" + icon = "/emojis/1f1e6-1f1ea.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 = "/icons/azure.png" + mutable = false + option { + name = "1 vCPU, 2 GiB RAM" + value = "Standard_B1ms" + } + option { + name = "2 vCPU, 8 GiB RAM" + value = "Standard_B2ms" + } + option { + name = "4 vCPU, 16 GiB RAM" + value = "Standard_B4ms" + } + option { + name = "8 vCPU, 32 GiB RAM" + value = "Standard_B8ms" + } + option { + name = "12 vCPU, 48 GiB RAM" + value = "Standard_B12ms" + } + option { + name = "16 vCPU, 64 GiB RAM" + value = "Standard_B16ms" + } + option { + name = "2 vCPU, 8 GiB RAM" + value = "Standard_D2as_v5" + } + option { + name = "4 vCPU, 16 GiB RAM" + value = "Standard_D4as_v5" + } + option { + name = "8 vCPU, 32 GiB RAM" + value = "Standard_D8as_v5" + } + option { + name = "16 vCPU, 64 GiB RAM" + value = "Standard_D16as_v5" + } + option { + name = "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 = "/icons/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 +192,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 +210,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 +271,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 +286,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 +338,6 @@ resource "coder_metadata" "home_info" { item { key = "size" - value = "${var.home_size} GiB" + value = "${data.coder_parameter.home_size.value} GiB" } } From 071f9acb934088076ff35d5bbb1c94de8f17af32 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 08:35:26 +0300 Subject: [PATCH 12/32] update aws removed --- examples/templates/aws-ecs-container/main.tf | 28 +++- examples/templates/aws-linux/main.tf | 167 ++++++++++++++----- examples/templates/aws-windows/main.tf | 163 +++++++++++++----- 3 files changed, 263 insertions(+), 95 deletions(-) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index 771c9a01b7561..c1b5cdd574a4f 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.14" + version = "~> 0.6.17" } aws = { source = "hashicorp/aws" @@ -11,17 +11,27 @@ 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" + 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" + default = "2048" + mutable = true } # configure AWS provider with creds present on Coder server host @@ -35,14 +45,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 = data.coder_parameter.cpu.value + memory = data.coder_parameter.memory.value essential = true user = "coder" command = ["sh", "-c", coder_agent.coder.init_script] diff --git a/examples/templates/aws-linux/main.tf b/examples/templates/aws-linux/main.tf index 7534163365e3a..8275e46e7f0be 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 = true + 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..f03255c03a589 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,134 @@ 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 = true + 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" { @@ -104,9 +185,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 +194,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" From 33e234c92ddd12ece9a1fc5ea905262515063cf4 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 15:39:33 +0300 Subject: [PATCH 13/32] update requested changes --- examples/templates/aws-ecs-container/main.tf | 6 ++++-- examples/templates/docker-with-dotfiles/main.tf | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index c1b5cdd574a4f..0724aee7c7aec 100644 --- a/examples/templates/aws-ecs-container/main.tf +++ b/examples/templates/aws-ecs-container/main.tf @@ -23,14 +23,16 @@ variable "ecs-cluster" { data "coder_parameter" "cpu" { name = "cpu" description = "The number of CPU units to reserve for the container" - default = "1024" + type = "number" + default = 1024 mutable = true } data "coder_parameter" "memory" { name = "memory" description = "The amount of memory (in MiB) to allow the container to use" - default = "2048" + type = "number" + default = 2048 mutable = true } diff --git a/examples/templates/docker-with-dotfiles/main.tf b/examples/templates/docker-with-dotfiles/main.tf index 6f9736c41a416..267161d55f8a0 100644 --- a/examples/templates/docker-with-dotfiles/main.tf +++ b/examples/templates/docker-with-dotfiles/main.tf @@ -33,7 +33,7 @@ data "coder_parameter" "docker_image" { default = "codercom/enterprise-base:ubuntu" icon = "/icon/docker.png" type = "string" - mutable = true + mutable = false } data "coder_parameter" "dotfiles_uri" { From db081e062d733fdbbce645aa5cda1dc1d02fc80e Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 15:39:44 +0300 Subject: [PATCH 14/32] update regions with city names --- examples/templates/azure-linux/main.tf | 147 +++++++++++++++++-------- 1 file changed, 101 insertions(+), 46 deletions(-) diff --git a/examples/templates/azure-linux/main.tf b/examples/templates/azure-linux/main.tf index e4aaea32f4019..1117862ef872c 100644 --- a/examples/templates/azure-linux/main.tf +++ b/examples/templates/azure-linux/main.tf @@ -18,105 +18,160 @@ data "coder_parameter" "location" { icon = "/emojis/" mutable = false option { - name = "East US" + name = "US (Virginia)" value = "eastus" icon = "/emojis/1f1fa-1f1f8.png" } option { - name = "South Central US" + name = "US (Texas)" value = "southcentralus" icon = "/emojis/1f1fa-1f1f8.png" } option { - name = "West US 2" + name = "US (Washington)" value = "westus2" icon = "/emojis/1f1fa-1f1f8.png" } option { - name = "Australia East" + 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 = "Canada (Quebec City)" + value = "canadaeast" + 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 = "Southeast Asia" - value = "southeastasia" - icon = "/emojis/1f1f8-1f1e6.png" + name = "Australia (Victoria)" + value = "australiasoutheast" + icon = "/emojis/1f1e6-1f1fa.png" } option { - name = "North Europe" - value = "northeurope" - icon = "/emojis/1f1f3-1f1ea.png" + name = "Australia (Canberra)" + value = "australiacentral" + icon = "/emojis/1f1e6-1f1fa.png" } option { - name = "West Europe" - value = "westeurope" - icon = "/emojis/1f1f3-1f1ea.png" + name = "China (Shanghai)" + value = "chinaeast" + icon = "/emojis/1f1e8-1f1f3.png" + } + option { + name = "China (Beijing)" + value = "chinanorth" + icon = "/emojis/1f1e8-1f1f3.png" } option { - name = "Central India" + name = "India (Pune)" value = "centralindia" icon = "/emojis/1f1ee-1f1f3.png" } option { - name = "East Asia" - value = "eastasia" - icon = "/emojis/1f1f0-1f1f7.png" + name = "India (Chennai)" + value = "southindia" + icon = "/emojis/1f1ee-1f1f3.png" } option { - name = "Japan East" + name = "Japan (Tokyo)" value = "japaneast" icon = "/emojis/1f1ef-1f1f5.png" } option { - name = "Brazil South" - value = "brazilsouth" - icon = "/emojis/1f1e7-1f1f7.png" + name = "Japan (Osaka)" + value = "japanwest" + icon = "/emojis/1f1ef-1f1f5.png" } option { - name = "Asia" - value = "asia" + name = "Korea (Seoul)" + value = "koreacentral" icon = "/emojis/1f1f0-1f1f7.png" } option { - name = "Asia Pacific" - value = "asiapacific" - icon = "/emojis/1f1f0-1f1f7.png" + name = "Europe (Ireland)" + value = "northeurope" + icon = "/emojis/1f1ea-1f1fa.png" } option { - name = "Australia" - value = "australia" - icon = "/emojis/1f1e6-1f1fa.png" + name = "Europe (Netherlands)" + value = "westeurope" + icon = "/emojis/1f1ea-1f1fa.png" } option { - name = "Brazil" - value = "brazil" - icon = "/emojis/1f1e7-1f1f7.png" + name = "France (Paris)" + value = "francecentral" + icon = "/emojis/1f1eb-1f1f7.png" } option { - name = "India" - value = "india" - icon = "/emojis/1f1ee-1f1f3.png" + name = "Germany (Frankfurt)" + value = "germanywestcentral" + icon = "/emojis/1f1e9-1f1ea.png" } option { - name = "Japan" - value = "japan" - icon = "/emojis/1f1ef-1f1f5.png" + name = "Norway (Oslo)" + value = "norwayeast" + icon = "/emojis/1f1f3-1f1f4.png" } option { - name = "South Africa" - value = "southafrica" - icon = "/emojis/1f1ff-1f1e6.png" + name = "Sweden (Gävle)" + value = "swedencentral" + icon = "/emojis/1f1f8-1f1ea.png" } option { - name = "Switzerland" - value = "switzerland" - icon = "/emojis/1f1e8-1f1ed.png" + name = "Qatar (Doha)" + value = "qatarcentral" + icon = "/emojis/1f1f6-1f1e6.png" } option { - name = "UAE" - value = "uae" + 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" + } + option { + name = "UK (Cardiff)" + value = "ukwest" + icon = "/emojis/1f1ec-1f1e7.png" + } } data "coder_parameter" "instance_type" { From e5f35f97fd56f28fde78930b9180425de88719dc Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 15:43:49 +0300 Subject: [PATCH 15/32] fix type --- examples/templates/aws-ecs-container/main.tf | 4 ++-- examples/templates/kubernetes/main.tf | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index 0724aee7c7aec..5b4c28b13e42d 100644 --- a/examples/templates/aws-ecs-container/main.tf +++ b/examples/templates/aws-ecs-container/main.tf @@ -24,7 +24,7 @@ data "coder_parameter" "cpu" { name = "cpu" description = "The number of CPU units to reserve for the container" type = "number" - default = 1024 + default = "1024" mutable = true } @@ -32,7 +32,7 @@ data "coder_parameter" "memory" { name = "memory" description = "The amount of memory (in MiB) to allow the container to use" type = "number" - default = 2048 + default = "2048" mutable = true } diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf index 49f6eca1197d5..e1237fe8b384d 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -83,6 +83,7 @@ data "coder_parameter" "memory" { data "coder_parameter" "home_disk_size" { name = "Home Disk Size (GB)" default = "10" + type = "number" icon = "/emojis/1f4be.png" mutable = false validation { From 152d9fa189cf52bb8d7d19d5706c2e35d1e31095 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 15:59:33 +0300 Subject: [PATCH 16/32] remove regions with no support for availability zones --- examples/templates/azure-linux/main.tf | 44 ++++---------------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/examples/templates/azure-linux/main.tf b/examples/templates/azure-linux/main.tf index 1117862ef872c..de210b422128e 100644 --- a/examples/templates/azure-linux/main.tf +++ b/examples/templates/azure-linux/main.tf @@ -22,6 +22,11 @@ data "coder_parameter" "location" { 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" @@ -47,11 +52,6 @@ data "coder_parameter" "location" { value = "canadacentral" icon = "/emojis/1f1e8-1f1e6.png" } - option { - name = "Canada (Quebec City)" - value = "canadaeast" - icon = "/emojis/1f1e8-1f1e6.png" - } option { name = "Brazil (Sao Paulo)" value = "brazilsouth" @@ -73,23 +73,8 @@ data "coder_parameter" "location" { icon = "/emojis/1f1e6-1f1fa.png" } option { - name = "Australia (Victoria)" - value = "australiasoutheast" - icon = "/emojis/1f1e6-1f1fa.png" - } - option { - name = "Australia (Canberra)" - value = "australiacentral" - icon = "/emojis/1f1e6-1f1fa.png" - } - option { - name = "China (Shanghai)" - value = "chinaeast" - icon = "/emojis/1f1e8-1f1f3.png" - } - option { - name = "China (Beijing)" - value = "chinanorth" + name = "China (Hebei)" + value = "chinanorth3" icon = "/emojis/1f1e8-1f1f3.png" } option { @@ -97,21 +82,11 @@ data "coder_parameter" "location" { value = "centralindia" icon = "/emojis/1f1ee-1f1f3.png" } - option { - name = "India (Chennai)" - value = "southindia" - icon = "/emojis/1f1ee-1f1f3.png" - } option { name = "Japan (Tokyo)" value = "japaneast" icon = "/emojis/1f1ef-1f1f5.png" } - option { - name = "Japan (Osaka)" - value = "japanwest" - icon = "/emojis/1f1ef-1f1f5.png" - } option { name = "Korea (Seoul)" value = "koreacentral" @@ -167,11 +142,6 @@ data "coder_parameter" "location" { value = "uksouth" icon = "/emojis/1f1ec-1f1e7.png" } - option { - name = "UK (Cardiff)" - value = "ukwest" - icon = "/emojis/1f1ec-1f1e7.png" - } } data "coder_parameter" "instance_type" { From e3edbedadea4f28b8f9f4bb83c273a60477349b1 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 16:13:55 +0300 Subject: [PATCH 17/32] add Switzerland --- examples/templates/azure-linux/main.tf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/templates/azure-linux/main.tf b/examples/templates/azure-linux/main.tf index de210b422128e..3f63e2b4f2036 100644 --- a/examples/templates/azure-linux/main.tf +++ b/examples/templates/azure-linux/main.tf @@ -122,6 +122,11 @@ data "coder_parameter" "location" { value = "swedencentral" icon = "/emojis/1f1f8-1f1ea.png" } + option { + name = "Switzerland (Zurich)" + value = "switzerlandnorth" + icon = "/emojis/1f1e8-1f1ed.png" + } option { name = "Qatar (Doha)" value = "qatarcentral" From 4bc2178285969c83ec1d830acaae9880cc486024 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 17:20:40 +0300 Subject: [PATCH 18/32] revert + refactor do-linux --- examples/templates/do-linux/main.tf | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/templates/do-linux/main.tf b/examples/templates/do-linux/main.tf index 8a663c37ca4ae..1993337b30ccf 100644 --- a/examples/templates/do-linux/main.tf +++ b/examples/templates/do-linux/main.tf @@ -22,7 +22,8 @@ variable "step1_do_project_id" { $ doctl projects list EOF - default = "0" + sensitive = true + validation { # make sure length of alphanumeric string is 36 condition = length(var.step1_do_project_id) == 36 @@ -32,7 +33,7 @@ variable "step1_do_project_id" { } variable "step2_do_admin_ssh_key" { - type = string + type = number description = <<-EOF Enter admin SSH key ID (some Droplet images require an SSH key to be set): @@ -42,13 +43,12 @@ variable "step2_do_admin_ssh_key" { $ doctl compute ssh-key list EOF - default = "0" + sensitive = true + validation { - # make sure value is a number - condition = can(regex("^[0-9]+$", var.step2_do_admin_ssh_key)) - error_message = "Invalid Digital Ocean SSH Key ID." + condition = var.step2_do_admin_ssh_key >= 0 + error_message = "Invalid Digital Ocean SSH key ID, a number is required." } - } data "coder_parameter" "droplet_image" { @@ -115,27 +115,27 @@ data "coder_parameter" "droplet_size" { icon = "/icon/memory.svg" mutable = false option { - name = "1 core / 1 GB RAM" + name = "1 vCPU, 1 GB RAM" value = "s-1vcpu-1gb" } option { - name = "1 core / 2 GB RAM" + name = "1 vCPU, 2 GB RAM" value = "s-1vcpu-2gb" } option { - name = "2 cores / 2 GB RAM" + name = "2 vCPU, 2 GB RAM" value = "s-2vcpu-2gb" } option { - name = "2 cores / 4 GB RAM" + name = "2 vCPU, 4 GB RAM" value = "s-2vcpu-4gb" } option { - name = "4 cores / 8 GB RAM" + name = "4 vCPU, 8 GB RAM" value = "s-4vcpu-8gb" } option { - name = "8 cores / 16 GB RAM" + name = "8 vCPU, 16 GB RAM" value = "s-8vcpu-16gb" } } @@ -269,7 +269,7 @@ resource "digitalocean_droplet" "workspace" { coder_agent_token = coder_agent.main.token }) # Required to provision Fedora. - ssh_keys = var.step1_do_project_id > 0 ? [var.step2_do_admin_ssh_key] : [] + ssh_keys = var.step2_do_admin_ssh_key > 0 ? [var.step2_do_admin_ssh_key] : [] } resource "digitalocean_project_resources" "project" { From 311b20c58da0ec8cf0015baf1ffeaec2b9100725 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 18:09:26 +0300 Subject: [PATCH 19/32] fix docker migration --- examples/templates/docker/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf index 6090af06df962..6df6868f5a978 100644 --- a/examples/templates/docker/main.tf +++ b/examples/templates/docker/main.tf @@ -95,7 +95,7 @@ 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 } From ad2002e50ca6c87a274133ab213669c7edb58f74 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 18:16:17 +0300 Subject: [PATCH 20/32] update azure-vm --- examples/templates/azure-linux/main.tf | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/templates/azure-linux/main.tf b/examples/templates/azure-linux/main.tf index 3f63e2b4f2036..c49ba0bcf62f4 100644 --- a/examples/templates/azure-linux/main.tf +++ b/examples/templates/azure-linux/main.tf @@ -6,7 +6,7 @@ terraform { } azurerm = { source = "hashicorp/azurerm" - version = "=3.0.0" + version = "~>3.47.0" } } } @@ -15,7 +15,7 @@ data "coder_parameter" "location" { name = "Location" description = "What location should your workspace live in?" default = "eastus" - icon = "/emojis/" + icon = "/emojis/1f310.png" mutable = false option { name = "US (Virginia)" @@ -156,47 +156,47 @@ data "coder_parameter" "instance_type" { icon = "/icons/azure.png" mutable = false option { - name = "1 vCPU, 2 GiB RAM" + name = "Standard_B1ms (1 vCPU, 2 GiB RAM)" value = "Standard_B1ms" } option { - name = "2 vCPU, 8 GiB RAM" + name = "Standard_B2ms (2 vCPU, 8 GiB RAM)" value = "Standard_B2ms" } option { - name = "4 vCPU, 16 GiB RAM" + name = "Standard_B4ms (4 vCPU, 16 GiB RAM)" value = "Standard_B4ms" } option { - name = "8 vCPU, 32 GiB RAM" + name = "Standard_B8ms (8 vCPU, 32 GiB RAM)" value = "Standard_B8ms" } option { - name = "12 vCPU, 48 GiB RAM" + name = "Standard_B12ms (12 vCPU, 48 GiB RAM)" value = "Standard_B12ms" } option { - name = "16 vCPU, 64 GiB RAM" + name = "Standard_B16ms (16 vCPU, 64 GiB RAM)" value = "Standard_B16ms" } option { - name = "2 vCPU, 8 GiB RAM" + name = "Standard_D2as_v5 (2 vCPU, 8 GiB RAM)" value = "Standard_D2as_v5" } option { - name = "4 vCPU, 16 GiB RAM" + name = "Standard_D4as_v5 (4 vCPU, 16 GiB RAM)" value = "Standard_D4as_v5" } option { - name = "8 vCPU, 32 GiB RAM" + name = "Standard_D8as_v5 (8 vCPU, 32 GiB RAM)" value = "Standard_D8as_v5" } option { - name = "16 vCPU, 64 GiB RAM" + name = "Standard_D16as_v5 (16 vCPU, 64 GiB RAM)" value = "Standard_D16as_v5" } option { - name = "32 vCPU, 128 GiB RAM" + name = "Standard_D32as_v5 (32 vCPU, 128 GiB RAM)" value = "Standard_D32as_v5" } } From a7025879ea4107c0c7434559692e018c1d7a60f1 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 18:25:41 +0300 Subject: [PATCH 21/32] fix: docker-with-dotfiles --- examples/templates/docker-with-dotfiles/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/templates/docker-with-dotfiles/main.tf b/examples/templates/docker-with-dotfiles/main.tf index 267161d55f8a0..5c655d704d779 100644 --- a/examples/templates/docker-with-dotfiles/main.tf +++ b/examples/templates/docker-with-dotfiles/main.tf @@ -134,6 +134,6 @@ resource "coder_metadata" "container_info" { item { key = "image" - value = var.docker_image + value = data.coder_parameter.docker_image.value } } From aaa7800189030d19f6a97a77403d16e8f454d8cc Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 18:31:14 +0300 Subject: [PATCH 22/32] add icons --- site/static/icon/java.svg | 41 +++++++++++++++++++++++++++++++++++++++ site/static/icon/node.svg | 1 + 2 files changed, 42 insertions(+) create mode 100644 site/static/icon/java.svg create mode 100644 site/static/icon/node.svg 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 From eab122d038a28e0d3139c6173df4ee03de37c9a0 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 18:37:50 +0300 Subject: [PATCH 23/32] update docker_image icon --- examples/templates/docker-image-builds/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf index 1c5cc16692e17..a660cd2c5bc7e 100644 --- a/examples/templates/docker-image-builds/main.tf +++ b/examples/templates/docker-image-builds/main.tf @@ -55,7 +55,7 @@ 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" - icon = "/emojis/1f4bf.png" + icon = "/icon/docker.png" type = "string" mutable = false option { From 525bb3e97c36bd75c102428c1fcc01591be1c83b Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 14 Mar 2023 19:59:06 +0300 Subject: [PATCH 24/32] fix: flag emojis in do-linux --- examples/templates/do-linux/main.tf | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/templates/do-linux/main.tf b/examples/templates/do-linux/main.tf index 1993337b30ccf..b87d91d0d4172 100644 --- a/examples/templates/do-linux/main.tf +++ b/examples/templates/do-linux/main.tf @@ -163,67 +163,67 @@ data "coder_parameter" "region" { option { name = "New York 1" value = "nyc1" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "New York 2" value = "nyc2" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "New York 3" value = "nyc3" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "San Francisco 1" value = "sfo1" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "San Francisco 2" value = "sfo2" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "San Francisco 3" value = "sfo3" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "Amsterdam 2" value = "ams2" - icon = "/emojis/1f1f3_1f1f1.png" + icon = "/emojis/1f1f3-1f1f1.png" } option { name = "Amsterdam 3" value = "ams3" - icon = "/emojis/1f1f3_1f1f1.png" + icon = "/emojis/1f1f3-1f1f1.png" } option { name = "Singapore 1" value = "sgp1" - icon = "/emojis/1f1f8_1f1ec.png" + icon = "/emojis/1f1f8-1f1ec.png" } option { name = "London 1" value = "lon1" - icon = "/emojis/1f1ec_1f1e7.png" + icon = "/emojis/1f1ec-1f1e7.png" } option { name = "Frankfurt 1" value = "fra1" - icon = "/emojis/1f1e9_1f1ea.png" + icon = "/emojis/1f1e9-1f1ea.png" } option { name = "Toronto 1" value = "tor1" - icon = "/emojis/1f1e8_1f1e6.png" + icon = "/emojis/1f1e8-1f1e6.png" } option { name = "Bangalore 1" value = "blr1" - icon = "/emojis/1f1ee_1f1f3.png" + icon = "/emojis/1f1ee-1f1f3.png" } } From 994256a97a8b3f2adacb745265618df5cd1724b9 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Mar 2023 13:59:41 +0300 Subject: [PATCH 25/32] fix icons and default project google --- examples/templates/gcp-linux/main.tf | 19 +++++++++---------- examples/templates/gcp-vm-container/main.tf | 19 +++++++++---------- examples/templates/gcp-windows/main.tf | 14 ++++++-------- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/examples/templates/gcp-linux/main.tf b/examples/templates/gcp-linux/main.tf index 4b1d04d08e86f..41c8387a494fe 100644 --- a/examples/templates/gcp-linux/main.tf +++ b/examples/templates/gcp-linux/main.tf @@ -16,9 +16,7 @@ provider "coder" { } variable "project_id" { - type = string - description = "The Google Compute Project will be used to build your workspace." - default = "" + description = "Which Google Compute Project should your workspace live in?" } data "coder_parameter" "zone" { @@ -26,30 +24,31 @@ data "coder_parameter" "zone" { 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" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "North America (Central)" value = "us-central1-a" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "North America (West)" value = "us-west2-c" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "Europe (West)" value = "europe-west4-b" - icon = "/emojis/1f1ea_1f1fa.png" + icon = "/emojis/1f1ea-1f1fa.png" } option { name = "South America (East)" value = "southamerica-east1-a" - icon = "/emojis/1f1e7_1f1f7.png" + icon = "/emojis/1f1e7-1f1f7.png" } } @@ -58,10 +57,10 @@ provider "google" { project = var.project_id } -data "coder_workspace" "me" { +data "google_compute_default_service_account" "default" { } -data "google_compute_default_service_account" "default" { +data "coder_workspace" "me" { } resource "google_compute_disk" "root" { diff --git a/examples/templates/gcp-vm-container/main.tf b/examples/templates/gcp-vm-container/main.tf index 39da3542e10fc..447de56a1822d 100644 --- a/examples/templates/gcp-vm-container/main.tf +++ b/examples/templates/gcp-vm-container/main.tf @@ -16,9 +16,7 @@ provider "coder" { } variable "project_id" { - type = string - description = "The Google Compute Project will be used to build your workspace." - default = "" + description = "Which Google Compute Project should your workspace live in?" } data "coder_parameter" "zone" { @@ -26,30 +24,31 @@ data "coder_parameter" "zone" { 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" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "North America (Central)" value = "us-central1-a" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "North America (West)" value = "us-west2-c" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "Europe (West)" value = "europe-west4-b" - icon = "/emojis/1f1ea_1f1fa.png" + icon = "/emojis/1f1ea-1f1fa.png" } option { name = "South America (East)" value = "southamerica-east1-a" - icon = "/emojis/1f1e7_1f1f7.png" + icon = "/emojis/1f1e7-1f1f7.png" } } @@ -58,10 +57,10 @@ provider "google" { project = var.project_id } -data "coder_workspace" "me" { +data "google_compute_default_service_account" "default" { } -data "google_compute_default_service_account" "default" { +data "coder_workspace" "me" { } resource "coder_agent" "main" { diff --git a/examples/templates/gcp-windows/main.tf b/examples/templates/gcp-windows/main.tf index a6219c06a348e..db4cfc4129d42 100644 --- a/examples/templates/gcp-windows/main.tf +++ b/examples/templates/gcp-windows/main.tf @@ -16,9 +16,7 @@ provider "coder" { } variable "project_id" { - type = string - description = "The Google Compute Project will be used to build your workspace." - default = "" + description = "Which Google Compute Project should your workspace live in?" } data "coder_parameter" "zone" { @@ -29,27 +27,27 @@ data "coder_parameter" "zone" { option { name = "North America (Northeast)" value = "northamerica-northeast1-a" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "North America (Central)" value = "us-central1-a" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "North America (West)" value = "us-west2-c" - icon = "/emojis/1f1fa_1f1f8.png" + icon = "/emojis/1f1fa-1f1f8.png" } option { name = "Europe (West)" value = "europe-west4-b" - icon = "/emojis/1f1ea_1f1fa.png" + icon = "/emojis/1f1ea-1f1fa.png" } option { name = "South America (East)" value = "southamerica-east1-a" - icon = "/emojis/1f1e7_1f1f7.png" + icon = "/emojis/1f1e7-1f1f7.png" } } From 1bc57d12af3b71b20dd3a7d6c603cc3cffa3293e Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Mar 2023 15:21:47 +0300 Subject: [PATCH 26/32] remove default and hardcoded cpu and memory --- examples/templates/aws-ecs-container/main.tf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index 5b4c28b13e42d..786ac7660c608 100644 --- a/examples/templates/aws-ecs-container/main.tf +++ b/examples/templates/aws-ecs-container/main.tf @@ -17,7 +17,6 @@ provider "coder" { variable "ecs-cluster" { description = "Input the ECS cluster ARN to host the workspace" - default = "" } data "coder_parameter" "cpu" { @@ -53,8 +52,8 @@ resource "aws_ecs_task_definition" "workspace" { { name = "coder-workspace-${data.coder_workspace.me.id}" image = "codercom/enterprise-base:ubuntu" - cpu = data.coder_parameter.cpu.value - memory = data.coder_parameter.memory.value + cpu = 1024 + memory = 2048 essential = true user = "coder" command = ["sh", "-c", coder_agent.coder.init_script] From 9610e62fa2553f80833b38ca6f9579e778fec054 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Mar 2023 15:22:16 +0300 Subject: [PATCH 27/32] set Instance type to be immutable --- examples/templates/aws-linux/main.tf | 2 +- examples/templates/aws-windows/main.tf | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/templates/aws-linux/main.tf b/examples/templates/aws-linux/main.tf index 8275e46e7f0be..986a1088a17cb 100644 --- a/examples/templates/aws-linux/main.tf +++ b/examples/templates/aws-linux/main.tf @@ -109,7 +109,7 @@ data "coder_parameter" "instance_type" { name = "Instance Type" description = "What instance type should your workspace use?" default = "t3.micro" - mutable = true + mutable = false option { name = "2 vCPU, 1 GiB RAM" value = "t3.micro" diff --git a/examples/templates/aws-windows/main.tf b/examples/templates/aws-windows/main.tf index f03255c03a589..87c5b710a2c97 100644 --- a/examples/templates/aws-windows/main.tf +++ b/examples/templates/aws-windows/main.tf @@ -11,7 +11,6 @@ terraform { } } - # Last updated 2023-03-14 # aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort' data "coder_parameter" "region" { @@ -110,7 +109,7 @@ data "coder_parameter" "instance_type" { name = "Instance Type" description = "What instance type should your workspace use?" default = "t3.micro" - mutable = true + mutable = false option { name = "2 vCPU, 1 GiB RAM" value = "t3.micro" @@ -155,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 } From dcb34e26107c960aeae46ff5a436188a912e43cb Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Mar 2023 15:22:36 +0300 Subject: [PATCH 28/32] set zone to be immutable --- examples/templates/gcp-windows/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/templates/gcp-windows/main.tf b/examples/templates/gcp-windows/main.tf index db4cfc4129d42..e57a7adb5732e 100644 --- a/examples/templates/gcp-windows/main.tf +++ b/examples/templates/gcp-windows/main.tf @@ -24,6 +24,7 @@ data "coder_parameter" "zone" { type = "string" default = "us-central1-a" icon = "/emojis/1f30e.png" + mutable = false option { name = "North America (Northeast)" value = "northamerica-northeast1-a" From b4c46e00b8fc3302f4b6d0d7c2aa7a0a5c71409e Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Mar 2023 15:37:59 +0300 Subject: [PATCH 29/32] fix typo to fix icons --- examples/templates/azure-linux/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/templates/azure-linux/main.tf b/examples/templates/azure-linux/main.tf index c49ba0bcf62f4..7360ac9381f70 100644 --- a/examples/templates/azure-linux/main.tf +++ b/examples/templates/azure-linux/main.tf @@ -153,7 +153,7 @@ data "coder_parameter" "instance_type" { name = "Instance Type" description = "What instance type should your workspace use?" default = "Standard_B4ms" - icon = "/icons/azure.png" + icon = "/icon/azure.png" mutable = false option { name = "Standard_B1ms (1 vCPU, 2 GiB RAM)" @@ -206,7 +206,7 @@ data "coder_parameter" "home_size" { description = "How large would you like your home volume to be (in GB)?" default = 20 type = "number" - icon = "/icons/azure.png" + icon = "/icon/azure.png" mutable = false validation { min = 1 From d9b63cf2ff7652bd9e9ff7089f98543c375048aa Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Mar 2023 15:46:23 +0300 Subject: [PATCH 30/32] suggestions --- examples/templates/aws-ecs-container/main.tf | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index 786ac7660c608..e7869b1c270a5 100644 --- a/examples/templates/aws-ecs-container/main.tf +++ b/examples/templates/aws-ecs-container/main.tf @@ -52,8 +52,8 @@ resource "aws_ecs_task_definition" "workspace" { { 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] @@ -104,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 From 527854c1f3e181ebb74df186b735b7374d2c4fa5 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Mar 2023 15:59:46 +0300 Subject: [PATCH 31/32] update code-server to version `4.10.1` --- examples/templates/aws-ecs-container/main.tf | 2 +- examples/templates/aws-linux/main.tf | 2 +- examples/templates/docker-image-builds/main.tf | 2 +- examples/templates/docker/main.tf | 2 +- examples/templates/gcp-linux/main.tf | 2 +- examples/templates/gcp-vm-container/main.tf | 2 +- examples/templates/kubernetes-with-podman/main.tf | 2 +- examples/templates/kubernetes/main.tf | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index e7869b1c270a5..d162f5fffbe09 100644 --- a/examples/templates/aws-ecs-container/main.tf +++ b/examples/templates/aws-ecs-container/main.tf @@ -114,7 +114,7 @@ resource "coder_agent" "coder" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT } diff --git a/examples/templates/aws-linux/main.tf b/examples/templates/aws-linux/main.tf index 986a1088a17cb..235e4f092a66c 100644 --- a/examples/templates/aws-linux/main.tf +++ b/examples/templates/aws-linux/main.tf @@ -166,7 +166,7 @@ resource "coder_agent" "main" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT } diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf index a660cd2c5bc7e..d641a2722dc91 100644 --- a/examples/templates/docker-image-builds/main.tf +++ b/examples/templates/docker-image-builds/main.tf @@ -30,7 +30,7 @@ resource "coder_agent" "main" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT } diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf index 6df6868f5a978..7e0fa444a8255 100644 --- a/examples/templates/docker/main.tf +++ b/examples/templates/docker/main.tf @@ -33,7 +33,7 @@ resource "coder_agent" "main" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT diff --git a/examples/templates/gcp-linux/main.tf b/examples/templates/gcp-linux/main.tf index 41c8387a494fe..d3411ceae95cc 100644 --- a/examples/templates/gcp-linux/main.tf +++ b/examples/templates/gcp-linux/main.tf @@ -83,7 +83,7 @@ resource "coder_agent" "main" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT } diff --git a/examples/templates/gcp-vm-container/main.tf b/examples/templates/gcp-vm-container/main.tf index 447de56a1822d..5fd45be292ba3 100644 --- a/examples/templates/gcp-vm-container/main.tf +++ b/examples/templates/gcp-vm-container/main.tf @@ -74,7 +74,7 @@ resource "coder_agent" "main" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT } diff --git a/examples/templates/kubernetes-with-podman/main.tf b/examples/templates/kubernetes-with-podman/main.tf index 01ea4f52adea6..44b62691dae99 100644 --- a/examples/templates/kubernetes-with-podman/main.tf +++ b/examples/templates/kubernetes-with-podman/main.tf @@ -82,7 +82,7 @@ resource "coder_agent" "dev" { #!/bin/sh # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & # Run once to avoid unnecessary warning: "/" is not a shared mount diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf index e1237fe8b384d..95728d947dce3 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -108,7 +108,7 @@ resource "coder_agent" "main" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT } From bdbe70991862a810f55209fc408893754e4132bf Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 15 Mar 2023 16:04:54 +0300 Subject: [PATCH 32/32] Revert "update code-server to version `4.10.1`" This reverts commit 527854c1f3e181ebb74df186b735b7374d2c4fa5. --- examples/templates/aws-ecs-container/main.tf | 2 +- examples/templates/aws-linux/main.tf | 2 +- examples/templates/docker-image-builds/main.tf | 2 +- examples/templates/docker/main.tf | 2 +- examples/templates/gcp-linux/main.tf | 2 +- examples/templates/gcp-vm-container/main.tf | 2 +- examples/templates/kubernetes-with-podman/main.tf | 2 +- examples/templates/kubernetes/main.tf | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/templates/aws-ecs-container/main.tf b/examples/templates/aws-ecs-container/main.tf index d162f5fffbe09..e7869b1c270a5 100644 --- a/examples/templates/aws-ecs-container/main.tf +++ b/examples/templates/aws-ecs-container/main.tf @@ -114,7 +114,7 @@ resource "coder_agent" "coder" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT } diff --git a/examples/templates/aws-linux/main.tf b/examples/templates/aws-linux/main.tf index 235e4f092a66c..986a1088a17cb 100644 --- a/examples/templates/aws-linux/main.tf +++ b/examples/templates/aws-linux/main.tf @@ -166,7 +166,7 @@ resource "coder_agent" "main" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT } diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf index d641a2722dc91..a660cd2c5bc7e 100644 --- a/examples/templates/docker-image-builds/main.tf +++ b/examples/templates/docker-image-builds/main.tf @@ -30,7 +30,7 @@ resource "coder_agent" "main" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT } diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf index 7e0fa444a8255..6df6868f5a978 100644 --- a/examples/templates/docker/main.tf +++ b/examples/templates/docker/main.tf @@ -33,7 +33,7 @@ resource "coder_agent" "main" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT diff --git a/examples/templates/gcp-linux/main.tf b/examples/templates/gcp-linux/main.tf index d3411ceae95cc..41c8387a494fe 100644 --- a/examples/templates/gcp-linux/main.tf +++ b/examples/templates/gcp-linux/main.tf @@ -83,7 +83,7 @@ resource "coder_agent" "main" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT } diff --git a/examples/templates/gcp-vm-container/main.tf b/examples/templates/gcp-vm-container/main.tf index 5fd45be292ba3..447de56a1822d 100644 --- a/examples/templates/gcp-vm-container/main.tf +++ b/examples/templates/gcp-vm-container/main.tf @@ -74,7 +74,7 @@ resource "coder_agent" "main" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT } diff --git a/examples/templates/kubernetes-with-podman/main.tf b/examples/templates/kubernetes-with-podman/main.tf index 44b62691dae99..01ea4f52adea6 100644 --- a/examples/templates/kubernetes-with-podman/main.tf +++ b/examples/templates/kubernetes-with-podman/main.tf @@ -82,7 +82,7 @@ resource "coder_agent" "dev" { #!/bin/sh # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & # Run once to avoid unnecessary warning: "/" is not a shared mount diff --git a/examples/templates/kubernetes/main.tf b/examples/templates/kubernetes/main.tf index 95728d947dce3..e1237fe8b384d 100644 --- a/examples/templates/kubernetes/main.tf +++ b/examples/templates/kubernetes/main.tf @@ -108,7 +108,7 @@ resource "coder_agent" "main" { set -e # install and start code-server - curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.10.1 + curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.8.3 /tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 & EOT }