Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: update templates to use rich parameters #6397

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
986423a
update templates to use rich parameters
matifali Mar 1, 2023
aed5f6c
more icons
matifali Mar 1, 2023
abec445
fix do-linux
matifali Mar 1, 2023
2f17c1d
fix: docker-image-builds
matifali Mar 1, 2023
31824c3
fix kubernetes
matifali Mar 1, 2023
d0ab600
add friendly names to do-linux
matifali Mar 1, 2023
9b5d632
Merge branch 'coder:main' into rich-params-examples
matifali Mar 2, 2023
eab5ff8
Merge branch 'coder:main' into rich-params-examples
matifali Mar 3, 2023
78d5eb4
Merge branch 'coder:main' into rich-params-examples
matifali Mar 7, 2023
5d3bdf7
Merge branch 'coder:main' into rich-params-examples
matifali Mar 14, 2023
59b18d1
use managed variables for do-linux
matifali Mar 14, 2023
a84db0b
update docker examples
matifali Mar 14, 2023
4caa9ea
update gcp
matifali Mar 14, 2023
3c3c0ef
update kubernetes
matifali Mar 14, 2023
ad0f454
update azure-vm
matifali Mar 14, 2023
071f9ac
update aws
matifali Mar 14, 2023
33e234c
update requested changes
matifali Mar 14, 2023
db081e0
update regions with city names
matifali Mar 14, 2023
e5f35f9
fix type
matifali Mar 14, 2023
152d9fa
remove regions with no support for availability zones
matifali Mar 14, 2023
e3edbed
add Switzerland
matifali Mar 14, 2023
4bc2178
revert + refactor do-linux
matifali Mar 14, 2023
311b20c
fix docker migration
matifali Mar 14, 2023
ad2002e
update azure-vm
matifali Mar 14, 2023
a702587
fix: docker-with-dotfiles
matifali Mar 14, 2023
aaa7800
add icons
matifali Mar 14, 2023
eab122d
update docker_image icon
matifali Mar 14, 2023
525bb3e
fix: flag emojis in do-linux
matifali Mar 14, 2023
994256a
fix icons and default project google
matifali Mar 15, 2023
1bc57d1
remove default and hardcoded cpu and memory
matifali Mar 15, 2023
9610e62
set Instance type to be immutable
matifali Mar 15, 2023
dcb34e2
set zone to be immutable
matifali Mar 15, 2023
b4c46e0
fix typo to fix icons
matifali Mar 15, 2023
d9b63cf
suggestions
matifali Mar 15, 2023
527854c
update code-server to version `4.10.1`
matifali Mar 15, 2023
bdbe709
Revert "update code-server to version `4.10.1`"
matifali Mar 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions examples/templates/aws-ecs-container/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "~> 0.6.12"
version = "~> 0.6.17"
}
aws = {
source = "hashicorp/aws"
Expand All @@ -11,16 +11,28 @@ terraform {
}
}

provider "coder" {
feature_use_managed_variables = true
}

variable "ecs-cluster" {
description = "Input the ECS cluster ARN to host the workspace"
default = ""
}
variable "cpu" {
default = "1024"

data "coder_parameter" "cpu" {
name = "cpu"
description = "The number of CPU units to reserve for the container"
type = "number"
default = "1024"
mutable = true
}

variable "memory" {
default = "2048"
data "coder_parameter" "memory" {
name = "memory"
description = "The amount of memory (in MiB) to allow the container to use"
type = "number"
default = "2048"
mutable = true
}

# configure AWS provider with creds present on Coder server host
Expand All @@ -34,14 +46,14 @@ resource "aws_ecs_task_definition" "workspace" {
family = "coder"

requires_compatibilities = ["EC2"]
cpu = var.cpu
memory = var.memory
cpu = data.coder_parameter.cpu.value
memory = data.coder_parameter.memory.value
container_definitions = jsonencode([
{
name = "coder-workspace-${data.coder_workspace.me.id}"
image = "codercom/enterprise-base:ubuntu"
cpu = 1024
memory = 2048
cpu = tonumber(data.coder_parameter.cpu.value)
memory = tonumber(data.coder_parameter.memory.value)
essential = true
user = "coder"
command = ["sh", "-c", coder_agent.coder.init_script]
Expand Down Expand Up @@ -92,11 +104,10 @@ resource "aws_ecs_service" "workspace" {
data "coder_workspace" "me" {}

resource "coder_agent" "coder" {
arch = "amd64"
auth = "token"
os = "linux"
dir = "/home/coder"

arch = "amd64"
auth = "token"
os = "linux"
dir = "/home/coder"
login_before_ready = false
startup_script_timeout = 180
startup_script = <<-EOT
Expand Down
167 changes: 123 additions & 44 deletions examples/templates/aws-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = "~> 0.6.12"
version = "~> 0.6.17"
}
aws = {
source = "hashicorp/aws"
Expand All @@ -11,53 +11,133 @@ terraform {
}
}

# Last updated 2022-05-31
# Last updated 2023-03-14
# aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort'
variable "region" {
description = "What region should your workspace live in?"
data "coder_parameter" "region" {
name = "Region"
description = "The region to deploy the workspace in."
default = "us-east-1"
validation {
condition = contains([
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-southeast-1",
"ap-southeast-2",
"ca-central-1",
"eu-central-1",
"eu-north-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2"
], var.region)
error_message = "Invalid region!"
mutable = false
option {
name = "Asia Pacific (Tokyo)"
value = "ap-northeast-1"
icon = "/emojis/1f1ef-1f1f5.png"
}
option {
name = "Asia Pacific (Seoul)"
value = "ap-northeast-2"
icon = "/emojis/1f1f0-1f1f7.png"
}
option {
name = "Asia Pacific (Osaka-Local)"
value = "ap-northeast-3"
icon = "/emojis/1f1f0-1f1f7.png"
}
option {
name = "Asia Pacific (Mumbai)"
value = "ap-south-1"
icon = "/emojis/1f1f0-1f1f7.png"
}
option {
name = "Asia Pacific (Singapore)"
value = "ap-southeast-1"
icon = "/emojis/1f1f0-1f1f7.png"
}
option {
name = "Asia Pacific (Sydney)"
value = "ap-southeast-2"
icon = "/emojis/1f1f0-1f1f7.png"
}
option {
name = "Canada (Central)"
value = "ca-central-1"
icon = "/emojis/1f1e8-1f1e6.png"
}
option {
name = "EU (Frankfurt)"
value = "eu-central-1"
icon = "/emojis/1f1ea-1f1fa.png"
}
option {
name = "EU (Stockholm)"
value = "eu-north-1"
icon = "/emojis/1f1ea-1f1fa.png"
}
option {
name = "EU (Ireland)"
value = "eu-west-1"
icon = "/emojis/1f1ea-1f1fa.png"
}
option {
name = "EU (London)"
value = "eu-west-2"
icon = "/emojis/1f1ea-1f1fa.png"
}
option {
name = "EU (Paris)"
value = "eu-west-3"
icon = "/emojis/1f1ea-1f1fa.png"
}
option {
name = "South America (São Paulo)"
value = "sa-east-1"
icon = "/emojis/1f1e7-1f1f7.png"
}
option {
name = "US East (N. Virginia)"
value = "us-east-1"
icon = "/emojis/1f1fa-1f1f8.png"
}
option {
name = "US East (Ohio)"
value = "us-east-2"
icon = "/emojis/1f1fa-1f1f8.png"
}
option {
name = "US West (N. California)"
value = "us-west-1"
icon = "/emojis/1f1fa-1f1f8.png"
}
option {
name = "US West (Oregon)"
value = "us-west-2"
icon = "/emojis/1f1fa-1f1f8.png"
}
}

variable "instance_type" {
data "coder_parameter" "instance_type" {
name = "Instance Type"
description = "What instance type should your workspace use?"
default = "t3.micro"
validation {
condition = contains([
"t3.micro",
"t3.small",
"t3.medium",
"t3.large",
"t3.xlarge",
"t3.2xlarge",
], var.instance_type)
error_message = "Invalid instance type!"
mutable = false
option {
name = "2 vCPU, 1 GiB RAM"
value = "t3.micro"
}
option {
name = "2 vCPU, 2 GiB RAM"
value = "t3.small"
}
option {
name = "2 vCPU, 4 GiB RAM"
value = "t3.medium"
}
option {
name = "2 vCPU, 8 GiB RAM"
value = "t3.large"
}
option {
name = "4 vCPU, 16 GiB RAM"
value = "t3.xlarge"
}
option {
name = "8 vCPU, 32 GiB RAM"
value = "t3.2xlarge"
}
}

provider "aws" {
region = var.region
region = data.coder_parameter.region.value
}

data "coder_workspace" "me" {
Expand All @@ -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
Expand Down Expand Up @@ -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 = {
Expand All @@ -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"
Expand Down
Loading