feat(registry/coder/modules/aws-region): regions.json catalog, default_availability_zone output, optional parameter - #1138
Draft
phorcys420 wants to merge 12 commits into
Draft
phorcys420 wants to merge 12 commits into
phorcys420 wants to merge 12 commits into
Conversation
…n and expose availability_zone
Contributor
Module Scorecard Check
|
| Theme | Before | After |
|---|---|---|
| Presentation & Onboarding | 17 / 17 | 17 / 17 |
| Integration | — | — |
| Credential Hygiene | N/A | 16 / 20 |
| Restricted-Environment | N/A | N/A |
| Engineering Quality | 10 / 10 | 10 / 10 |
| Overall | 100 / 100 | 91 / 100 |
Full scorecard for this PR
| Presentation & Onboarding | Credential Hygiene | Restricted-Environment Readiness | Engineering Quality | Overall |
|---|---|---|---|---|
| 17 / 17 | 16 / 20 | N/A | 10 / 10 | 91 / 100 |
Drilldown
Presentation & Onboarding — 17 / 17
| Criterion | Max | Score | Notes |
|---|---|---|---|
| Configuration-mode examples | 12 | 12 | Five documented examples cover every major mode: basic default selection, AZ output usage, create_parameter = false (outputs-only mode), custom_names/custom_icons overrides, and exclude filtering. Each example uses sensible defaults and is self-contained. |
| Visual preview | 5 | 5 | Three embedded images verified to exist: aws-regions.png (112.7 KB), aws-custom.png (52.8 KB), aws-exclude.png (56.2 KB). |
Credential Hygiene — 16 / 20
| Criterion | Max | Score | Notes |
|---|---|---|---|
| Secrets marked sensitive | 16 | 16 | The module contains no sensitive inputs (no API keys, tokens, or credentials). All variables are non-sensitive configuration (region IDs, display names, icons, booleans). README examples contain no inline secrets. Vacuously satisfied. |
| Non-hardcoded auth path | 4 | 0 | The module performs no authentication and interacts with no external service that requires credentials. No README section documents an auth path (ServiceAccount, IAM, API key helper, etc.) because none is needed, but the criterion is not marked "if applicable" and no such path is demonstrated. |
Restricted-Environment Readiness — N/A
All four criteria are N/A: the module downloads or installs nothing (it reads a local regions.json file via Terraform's file() function) and executes no scripts during deployment. The bash script in the README is a developer utility for regenerating the catalog, not part of the module's execution path.
| Criterion | Max | Score | Notes |
|---|---|---|---|
| Mirrorable artifact source | 5 | N/A | No tool is downloaded or installed; regions.json is a local file read via file(). |
| Bring-your-own binary | 10 | N/A | No binary is downloaded or installed. |
| Egress transparency | 3 | N/A | No external endpoints are contacted at install or runtime. |
| Runs without sudo | 2 | N/A | No scripts execute during module deployment. |
Engineering Quality — 10 / 10
| Criterion | Max | Score | Notes |
|---|---|---|---|
| Input quality | 6 | 6 | All 9 variables have clear description fields and sensible defaults. default and exclude include validation blocks with regex (^[a-z]{2}-[a-z]+-[0-9]+$) and descriptive error_message strings. create_parameter and mutable have appropriate boolean defaults. |
| Test coverage | 4 | 4 | main.tftest.hcl contains 10 test runs covering all business-logic paths: parameter name, order propagation, full-region option count, empty-default behavior, custom default, regions catalog output, exclusion, custom name/icon overrides, create_parameter = false mode, and the no-parameter/no-default edge case. Mix of plan and apply commands is appropriate. No TypeScript component exists (pure HCL module). |
Overall — 91 / 100
Raw 43 / 47 → round(43 / 47 × 100) = 91
Tip
You can run this locally by telling your agent: "review this module against .github/scorecard/SCORECARD.md".
Scored against SCORECARD.md with solstice-1. Language-model scores are advisory.
…e flags, rename AZ output - Move the flag emoji mapping into main.tf (flags map keyed by country); regions.json now stores value/name/country only. - Rename output availability_zone -> default_availability_zone. - Add create_parameter (default true); when false the picker is skipped and outputs fall back to var.default so admins can use the outputs only. - Remove the terraform test file. - Document how to regenerate regions.json via the AWS CLI.
Member
Author
|
just need to test |
…parameters
Coder's dynamic parameters preview resolves file() relative to the module's own
directory, while Terraform resolves it relative to the root module. The previous
file("${path.module}/regions.json") therefore returned nothing under preview, so
the parameter rendered as a free-text input with no options.
Read the catalog with try(file("${path.module}/regions.json"), file("regions.json"))
so it loads under both engines. Verified with coder/preview (radio, 28 options)
and terraform apply.
…validation Recover the module scorecard Engineering Quality points lost when the tests were removed: - Restore main.tftest.hcl covering options rendering, outputs, exclude, custom names/icons, and the create_parameter toggle (9 runs). - Add self-contained validation to default and exclude (region ID format), compatible with terraform >= 1.0.
Use null instead of an empty-string sentinel for the default region: - var.default now defaults to null and validates null or a region ID. - coder_parameter reads default = var.default directly (no "" -> null shim). - Add a test for create_parameter = false with no default (value null).
…names
The catalog mixed "EU (...)" and "Europe (...)" display names. Align every
European region to AWS's longName form ("Europe (...)"), which is what the
documented AWS CLI regeneration returns, so the names stay consistent and
reproducible.
The per-region field was named "country", but its value is a flag code such as "eu" for the shared European flag, which is not a country. Rename it to "flag" across regions.json, main.tf, the tests, and the README.
…ingle script Replace the print-and-hand-edit steps with one script that writes regions.json end to end: region names from the global-infrastructure longName SSM parameters, and flag from the lowercased geolocationCountry (eu-* regions share the eu flag).
regions.json now stores only region ID and display name; the regeneration script emits just those. main.tf derives each region's flag from its ID: a region uses its geographic prefix's flag (us-*, eu-*, ...) with explicit entries for the multi-country Asia Pacific and Middle East prefixes, then resolves the emoji from flag_emojis. Verified options and icons render under coder/preview and terraform apply.
Replace the flag_emojis + prefix_flags + region_flags + derived region_flag machinery with a single region_icons map (region ID -> emoji) and a direct lookup. Drops the redundant flag code field from the regions output; the icon is the flag.
matifali
reviewed
Sep 24, 2026
|
|
||
| ```tf | ||
| module "aws-region" { | ||
| module "aws_region" { |
matifali
approved these changes
Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactors
aws-regioninto a data-driven catalog (following theaws-ec2-instance-typepattern), adds region/AZ outputs, makes the parameter optional, and keeps the region picker working under Coder dynamic parameters.What changed
regions.json: generated catalog of{value, name, icon}per region, loaded withjsondecodeso the module needs no AWS provider or credentials at plan time.regions.jsonby the documented regenerate script;main.tfjust readsregion.icon, so there is no icon map in Terraform.default_availability_zoneoutput: resolves the selected region to a concrete zone (e.g.us-east-1a), replacing the"${region}a"guess the AWS templates do inline.regionsoutput: the full catalog keyed by region ID (name,icon,default_availability_zone).create_parameter(defaulttrue): setfalseto skip thecoder_parameterand use the outputs only;valuefalls back tovar.default.try(file("${path.module}/regions.json"), file("regions.json"))so options render under both Terraform and Coder'spreviewevaluator, which resolvefile()relative to different base directories.defaultandexclude(region ID format).main.tftest.hclcovers option rendering, outputs,exclude, custom names/icons, and thecreate_parametertoggle.regions.jsonvia the AWS CLI.1.0.31->1.1.0.No breaking input changes. The new output is named
default_availability_zone(it was not part of a prior release).Testing
terraform test(10 runs) passterraform validate,terraform fmt,prettier, and the README validator are cleancoder/preview(radio, 28 options, icons sourced from the JSON) and viaterraform applyImplementation notes & decisions
regions.json(names and icons) was derived from the originalmain.tfregion map, so names/icons are byte-identical; theeugrouping (all European regions share the EU flag) is preserved.longNameparameter, the flag from SSMgeolocationCountry(lowercased) converted to Coder's regional-indicator emoji asset, witheu-*regions forced to the shared EU flag. Terraform stays lightweight and only reads what the script emits.default_availability_zoneis computed as<region>a(every commercial AWS region exposes anazone), matching what the AWS templates already do.previewresolvesfile()relative to the module directory while Terraform resolves it relative to the root module, sofile("${path.module}/...")alone renders zero options under dynamic parameters. Thetry()fallback loads the file under both.create_parameter = falseuses the standardcounttoggle; theregionscatalog output is always available.1.1.0per CONTRIBUTING (feature = minor); latest release tag isv1.0.31.