From b43210fddfc8631a5f81001e9a816795ddf84c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phorcys=20=F0=9F=90=BE?= <57866459+phorcys420@users.noreply.github.com> Date: Mon, 21 Sep 2026 15:30:20 +0000 Subject: [PATCH 1/3] refactor(templates): use aws-region module in aws-linux and aws-windows Replace the hand-rolled coder_parameter.region (17 static options) in the aws-linux and aws-windows templates with the maintained aws-region module (pinned ~> 1.0), matching aws-envbuilder. Repoints the aws provider, availability_zone, and the region metadata item to module.aws_region.value. The workspace parameter key changes from `region` to `aws_region` (the module hardcodes name = "aws_region"); default = "us-east-1" preserves the same default selection, so fresh builds are unaffected. --- registry/coder/templates/aws-linux/main.tf | 104 ++----------------- registry/coder/templates/aws-windows/main.tf | 104 ++----------------- 2 files changed, 16 insertions(+), 192 deletions(-) diff --git a/registry/coder/templates/aws-linux/main.tf b/registry/coder/templates/aws-linux/main.tf index 89b3bde9e..b70873849 100644 --- a/registry/coder/templates/aws-linux/main.tf +++ b/registry/coder/templates/aws-linux/main.tf @@ -12,99 +12,11 @@ terraform { } } -# Last updated 2023-03-14 -# aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort' -data "coder_parameter" "region" { - name = "region" - display_name = "Region" - description = "The region to deploy the workspace in." - default = "us-east-1" - 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)" - value = "ap-northeast-3" - icon = "/emojis/1f1ef-1f1f5.png" - } - option { - name = "Asia Pacific (Mumbai)" - value = "ap-south-1" - icon = "/emojis/1f1ee-1f1f3.png" - } - option { - name = "Asia Pacific (Singapore)" - value = "ap-southeast-1" - icon = "/emojis/1f1f8-1f1ec.png" - } - option { - name = "Asia Pacific (Sydney)" - value = "ap-southeast-2" - icon = "/emojis/1f1e6-1f1fa.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" - } +# See https://registry.coder.com/modules/coder/aws-region +module "aws_region" { + source = "registry.coder.com/coder/aws-region/coder" + version = "~> 1.0" + default = "us-east-1" } data "coder_parameter" "instance_type" { @@ -140,7 +52,7 @@ data "coder_parameter" "instance_type" { } provider "aws" { - region = data.coder_parameter.region.value + region = module.aws_region.value } data "coder_workspace" "me" {} @@ -240,7 +152,7 @@ data "cloudinit_config" "user_data" { resource "aws_instance" "dev" { ami = data.aws_ami.ubuntu.id - availability_zone = "${data.coder_parameter.region.value}a" + availability_zone = "${module.aws_region.value}a" instance_type = data.coder_parameter.instance_type.value user_data = data.cloudinit_config.user_data.rendered @@ -258,7 +170,7 @@ resource "coder_metadata" "workspace_info" { resource_id = aws_instance.dev.id item { key = "region" - value = data.coder_parameter.region.value + value = module.aws_region.value } item { key = "instance type" diff --git a/registry/coder/templates/aws-windows/main.tf b/registry/coder/templates/aws-windows/main.tf index 167b1b69f..001b36210 100644 --- a/registry/coder/templates/aws-windows/main.tf +++ b/registry/coder/templates/aws-windows/main.tf @@ -9,99 +9,11 @@ terraform { } } -# Last updated 2023-03-14 -# aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort' -data "coder_parameter" "region" { - name = "region" - display_name = "Region" - description = "The region to deploy the workspace in." - default = "us-east-1" - 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" - } +# See https://registry.coder.com/modules/coder/aws-region +module "aws_region" { + source = "registry.coder.com/coder/aws-region/coder" + version = "~> 1.0" + default = "us-east-1" } data "coder_parameter" "instance_type" { @@ -137,7 +49,7 @@ data "coder_parameter" "instance_type" { } provider "aws" { - region = data.coder_parameter.region.value + region = module.aws_region.value } data "coder_workspace" "me" { @@ -183,7 +95,7 @@ EOT resource "aws_instance" "dev" { ami = data.aws_ami.windows.id - availability_zone = "${data.coder_parameter.region.value}a" + availability_zone = "${module.aws_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 @@ -201,7 +113,7 @@ resource "coder_metadata" "workspace_info" { resource_id = aws_instance.dev.id item { key = "region" - value = data.coder_parameter.region.value + value = module.aws_region.value } item { key = "instance type" From 211d2315391d610830e570ca7339239b46686a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phorcys=20=F0=9F=90=BE?= <57866459+phorcys420@users.noreply.github.com> Date: Mon, 28 Sep 2026 22:06:00 +0000 Subject: [PATCH 2/3] refactor(templates): adopt aws-ec2-instance-type and aws-region AZ output Replace the hand-rolled instance_type coder_parameter in aws-linux and aws-windows with the aws-ec2-instance-type module (~> 1.0, default t3.micro), and bump aws-region to ~> 1.1 to use its new default_availability_zone output instead of interpolating "${region}a". The instance_type parameter key changes from `instance_type` to `aws_ec2_instance_type` (the module hardcodes the name). Default t3.micro is preserved; the t3 picker gains t3.nano. The availability_zone value is unchanged ("a"). --- registry/coder/templates/aws-linux/main.tf | 41 ++++---------------- registry/coder/templates/aws-windows/main.tf | 41 ++++---------------- 2 files changed, 16 insertions(+), 66 deletions(-) diff --git a/registry/coder/templates/aws-linux/main.tf b/registry/coder/templates/aws-linux/main.tf index b70873849..4fc861e3b 100644 --- a/registry/coder/templates/aws-linux/main.tf +++ b/registry/coder/templates/aws-linux/main.tf @@ -15,40 +15,15 @@ terraform { # See https://registry.coder.com/modules/coder/aws-region module "aws_region" { source = "registry.coder.com/coder/aws-region/coder" - version = "~> 1.0" + version = "~> 1.1" default = "us-east-1" } -data "coder_parameter" "instance_type" { - name = "instance_type" - display_name = "Instance type" - description = "What instance type should your workspace use?" - default = "t3.micro" - 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" - } +# See https://registry.coder.com/modules/coder/aws-ec2-instance-type +module "aws_ec2_instance_type" { + source = "registry.coder.com/coder/aws-ec2-instance-type/coder" + version = "~> 1.0" + default = "t3.micro" } provider "aws" { @@ -152,8 +127,8 @@ data "cloudinit_config" "user_data" { resource "aws_instance" "dev" { ami = data.aws_ami.ubuntu.id - availability_zone = "${module.aws_region.value}a" - instance_type = data.coder_parameter.instance_type.value + availability_zone = module.aws_region.default_availability_zone + instance_type = module.aws_ec2_instance_type.value user_data = data.cloudinit_config.user_data.rendered tags = { diff --git a/registry/coder/templates/aws-windows/main.tf b/registry/coder/templates/aws-windows/main.tf index 001b36210..5a477af45 100644 --- a/registry/coder/templates/aws-windows/main.tf +++ b/registry/coder/templates/aws-windows/main.tf @@ -12,40 +12,15 @@ terraform { # See https://registry.coder.com/modules/coder/aws-region module "aws_region" { source = "registry.coder.com/coder/aws-region/coder" - version = "~> 1.0" + version = "~> 1.1" default = "us-east-1" } -data "coder_parameter" "instance_type" { - name = "instance_type" - display_name = "Instance type" - description = "What instance type should your workspace use?" - default = "t3.micro" - 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" - } +# See https://registry.coder.com/modules/coder/aws-ec2-instance-type +module "aws_ec2_instance_type" { + source = "registry.coder.com/coder/aws-ec2-instance-type/coder" + version = "~> 1.0" + default = "t3.micro" } provider "aws" { @@ -95,8 +70,8 @@ EOT resource "aws_instance" "dev" { ami = data.aws_ami.windows.id - availability_zone = "${module.aws_region.value}a" - instance_type = data.coder_parameter.instance_type.value + availability_zone = module.aws_region.default_availability_zone + instance_type = module.aws_ec2_instance_type.value user_data = data.coder_workspace.me.transition == "start" ? local.user_data_start : local.user_data_end tags = { From 9f9c339901911d19b8cb895346e9e18712cbe3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phorcys=20=F0=9F=90=BE?= <57866459+phorcys420@users.noreply.github.com> Date: Mon, 28 Sep 2026 22:26:52 +0000 Subject: [PATCH 3/3] refactor(templates): adopt aws-ec2-instance-type and AZ output in aws-envbuilder Bump aws-envbuilder's aws-region pin to ~> 1.1 and source availability_zone from the new default_availability_zone output, and replace the hand-rolled instance_type coder_parameter with the aws-ec2-instance-type module (~> 1.0, default t3.micro). Mirrors the aws-linux and aws-windows changes. The instance_type parameter key changes from `instance_type` to `aws_ec2_instance_type`; default t3.micro is preserved. --- .../coder/templates/aws-envbuilder/main.tf | 43 ++++--------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/registry/coder/templates/aws-envbuilder/main.tf b/registry/coder/templates/aws-envbuilder/main.tf index 932672344..2bb36c26b 100644 --- a/registry/coder/templates/aws-envbuilder/main.tf +++ b/registry/coder/templates/aws-envbuilder/main.tf @@ -17,7 +17,7 @@ terraform { module "aws_region" { source = "registry.coder.com/coder/aws-region/coder" - version = "~> 1.0" + version = "~> 1.1" default = "us-east-1" } @@ -60,36 +60,11 @@ data "aws_ami" "ubuntu" { owners = ["099720109477"] # Canonical } -data "coder_parameter" "instance_type" { - name = "instance_type" - display_name = "Instance type" - description = "What instance type should your workspace use?" - default = "t3.micro" - 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" - } +# See https://registry.coder.com/modules/coder/aws-ec2-instance-type +module "aws_ec2_instance_type" { + source = "registry.coder.com/coder/aws-ec2-instance-type/coder" + version = "~> 1.0" + default = "t3.micro" } data "coder_parameter" "root_volume_size_gb" { @@ -156,7 +131,7 @@ data "aws_iam_instance_profile" "vm_instance_profile" { # Be careful when modifying the below locals! locals { # TODO: provide a way to pick the availability zone. - aws_availability_zone = "${module.aws_region.value}a" + aws_availability_zone = module.aws_region.default_availability_zone hostname = lower(data.coder_workspace.me.name) linux_user = "coder" @@ -247,7 +222,7 @@ data "cloudinit_config" "user_data" { resource "aws_instance" "vm" { ami = data.aws_ami.ubuntu.id availability_zone = local.aws_availability_zone - instance_type = data.coder_parameter.instance_type.value + instance_type = module.aws_ec2_instance_type.value iam_instance_profile = try(data.aws_iam_instance_profile.vm_instance_profile[0].name, null) root_block_device { volume_size = data.coder_parameter.root_volume_size_gb.value @@ -306,7 +281,7 @@ resource "coder_metadata" "info" { } item { key = "instance_type" - value = data.coder_parameter.instance_type.value + value = module.aws_ec2_instance_type.value } item { key = "ssh_pubkey"