Skip to content

refactor(templates): use aws-region and aws-ec2-instance-type modules across AWS templates - #1137

Open
phorcys420 wants to merge 5 commits into
mainfrom
phorcys/aws-region-module
Open

phorcys420 wants to merge 5 commits into
mainfrom
phorcys/aws-region-module

Conversation

@phorcys420

@phorcys420 phorcys420 commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Adopts the maintained aws-region and aws-ec2-instance-type modules across the AWS starter templates (aws-linux, aws-windows, aws-envbuilder), replacing hand-rolled region and instance_type coder_parameter blocks with the shared modules.

Per template

  • aws-linux / aws-windows: replace both hand-rolled region and instance_type parameters with module "aws_region" (~> 1.1) and module "aws_ec2_instance_type" (~> 1.0).
  • aws-envbuilder: already consumed aws_region; bump it ~> 1.0 → ~> 1.1 and replace the hand-rolled instance_type parameter with module "aws_ec2_instance_type" (~> 1.0).

Details

  • availability_zone now comes from the new module.aws_region.default_availability_zone output (added in aws-region v1.1.0) instead of interpolating "${region}a" — identical value.
  • aws-ec2-instance-type defaults to t3.micro with the default include = ["t3"] family.

Parameter key changes

The modules hardcode their parameter names, so the stable parameter keys change:

  • region → aws_region
  • instance_type → aws_ec2_instance_type

Defaults are preserved (us-east-1, t3.micro), so fresh builds are unaffected. The region list grows 17 → 29 and the instance-type picker gains t3.nano; the previous options remain a subset, nothing is removed. The coder_metadata display items keep their own key values, which are unrelated to the parameter names.

Context / decision log

Goal: replace the hand-rolled region / instance-type coder_parameter blocks in the AWS starter templates with the maintained aws-region and aws-ec2-instance-type modules, matching aws-envbuilder's existing region-module usage and cutting duplicated option data. AWS was the only cloud where region-module adoption was inconsistent (every GCP and Azure template already consumes its region module).

Scope: templates only — aws-linux, aws-windows, and aws-envbuilder main.tf. No module source changes.

Versions:

  • aws-region pinned ~> 1.1 (v1.1.0 introduces the default_availability_zone output used here); resolves to 1.1.0.
  • aws-ec2-instance-type pinned ~> 1.0; resolves to 1.0.0.

Behavior preservation:

  • Defaults unchanged: region us-east-1, instance type t3.micro; mutable = false preserved (module defaults).
  • availability_zone: module.aws_region.default_availability_zone returns "<region>a", identical to the old interpolation.
  • Region options 17 → 29; instance types gain t3.nano; previous options are subsets, so nothing is removed.
  • No README references the removed parameters, so no README changes were needed.

Validation: terraform init + terraform validate pass for all three templates; terraform fmt and prettier --check are clean.

Out of scope (separate follow-up): wiring the windows-rdp module into aws-windows. That template has no admin-password plumbing (its user_data only bootstraps the agent), so adding windows-rdp means introducing a random_password, setting the Windows Administrator password in user_data, and passing admin_username / admin_password — a bigger, template-specific change kept out of this PR.

Solves #1122


Generated by Coder Agents on behalf of @phorcys420.

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.
…tput

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 ("<region>a").
@phorcys420 phorcys420 changed the title refactor(templates): use aws-region module in aws-linux and aws-windows refactor(templates): use aws-region and aws-ec2-instance-type modules in aws-linux and aws-windows Sep 28, 2026
…-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.
@phorcys420 phorcys420 changed the title refactor(templates): use aws-region and aws-ec2-instance-type modules in aws-linux and aws-windows refactor(templates): use aws-region and aws-ec2-instance-type modules across AWS templates Sep 28, 2026
@phorcys420
phorcys420 marked this pull request as ready for review September 28, 2026 23:27

@matifali matifali left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for doing this. Templates look way, more cleaner now.

Comment thread registry/coder/templates/aws-linux/main.tf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants