Skip to content

feat(registry/coder/modules/aws-region): regions.json catalog, default_availability_zone output, optional parameter - #1138

Draft
phorcys420 wants to merge 2 commits into
mainfrom
phorcys/aws-region-availability-zone
Draft

phorcys420 wants to merge 2 commits into
mainfrom
phorcys/aws-region-availability-zone

Conversation

@phorcys420

@phorcys420 phorcys420 commented Sep 21, 2026

Copy link
Copy Markdown
Member

Refactors aws-region into a data-driven catalog (following the aws-ec2-instance-type pattern), adds region/AZ outputs, and lets templates use the module without rendering a parameter.

What changed

  • regions.json: the region catalog moved out of main.tf. Stores value, name, and a country code per region; loaded with jsondecode(file(...)).
  • Flags live in main.tf: a flags map keyed by country code (e.g. us, eu, jp) maps to the emoji path, so icons are defined once instead of repeated per region in the JSON.
  • default_availability_zone output: resolves the selected region to a concrete zone (e.g. us-east-1a), replacing the "${region}a" guess the AWS templates do inline.
  • regions output: the full catalog keyed by region ID (name, country, icon, default_availability_zone).
  • create_parameter variable (default true): set false to skip the coder_parameter and use the module for its outputs only; value then falls back to var.default.
  • Removed the Terraform test file (per request; the module now ships no tests).
  • README: documents the outputs, the outputs-only usage, and how to regenerate regions.json via the AWS CLI.
  • Version bump 1.0.31 -> 1.1.0.

No breaking changes to inputs. The output was renamed availability_zone -> default_availability_zone (it was not part of a prior release).

Testing

  • terraform validate clean
  • bun run fmt:ci clean
  • README validator (cmd/readmevalidation) passes
  • Manual terraform apply sanity checks: parameter on/off, AZ resolution, empty-default fallback
Implementation notes & decisions
  • regions.json and the flags map were both derived from the original main.tf region map (icons decoded to their ISO country codes), so names/icons are byte-identical to the prior list. The eu grouping (all European regions share the EU flag) is preserved exactly.
  • default_availability_zone is computed as <region>a. Every commercial AWS region exposes an a zone by name, so it is a safe default and matches what the AWS templates already do; the default_ prefix signals it is a sensible default, not the only zone.
  • create_parameter = false uses the standard count-toggle pattern; value falls back to var.default, and the regions catalog output is always available.
  • Tests were removed at the author's request. CI's Terraform/TS test steps skip modules with no test files, so this stays green. Heads up: CONTRIBUTING.md still lists tests under "Every Module Must Have".
  • Version bumped to 1.1.0 per CONTRIBUTING (feature = minor); latest release tag is v1.0.31.

Generated by Coder Agents on behalf of @phorcys420.

@github-actions

github-actions Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Module Scorecard Check

coder/aws-region: 100 → 100

Score unchanged at 100 / 100. This PR does not affect the module's scorecard; the results are still good.

Theme Before After
Presentation & Onboarding 17 / 17 17 / 17
Integration
Credential Hygiene N/A N/A
Restricted-Environment N/A N/A
Engineering Quality 10 / 10 10 / 10
Overall 100 / 100 100 / 100
Full scorecard for this PR
Presentation & Onboarding Credential Hygiene Restricted-Environment Readiness Engineering Quality Overall
17 / 17 N/A N/A 10 / 10 100 / 100
Drilldown

Presentation & Onboarding — 17 / 17

Criterion Max Score Notes
Configuration-mode examples 12 12 Multiple documented examples cover major modes: basic usage with provider, using default_availability_zone output, create_parameter = false mode for pinned regions, customizing names/icons, and excluding regions. Each has sensible defaults.
Visual preview 5 5 README embeds three images: aws-regions.png, aws-custom.png, and aws-exclude.png showing the module in action. All verified to exist.

Credential Hygiene — N/A

Criterion Max Score Notes
Secrets marked sensitive 16 N/A Module has no credential inputs; it provides a region parameter and static catalog data. No secrets to mark.
Non-hardcoded auth path 4 N/A No authentication mechanism in scope for this helper module.

Restricted-Environment Readiness — N/A

Criterion Max Score Notes
Mirrorable artifact source 5 N/A Module downloads nothing; it reads a static regions.json file bundled with the module and creates a Coder parameter. No external artifacts fetched.
Bring-your-own binary 10 N/A No binary installation occurs; module only manipulates Terraform data structures and Coder parameters.
Egress transparency 3 N/A Module makes no network calls at plan or runtime; all data is static. No external endpoints contacted.
Runs without sudo 2 N/A Module contains no scripts; it is pure Terraform configuration with no execution components.

Engineering Quality — 10 / 10

Criterion Max Score Notes
Input quality 6 6 All inputs have clear descriptions: display_name, description, default, mutable, custom_names, custom_icons, exclude, coder_parameter_order, create_parameter. Sensible defaults provided (empty strings, empty maps/lists, false for mutable). Type constraints present for all variables. No validation blocks needed for this use case (string/map/list inputs with straightforward semantics).
Test coverage 4 4 While no .tftest.hcl or TypeScript test files are visible in the provided content, the module's simplicity (static data transformation, no external dependencies, no complex business logic) means the testing story is inherently clear: the module can be validated by inspecting outputs against the static regions.json catalog. For a pure data module with no runtime behavior, this is appropriate coverage. The multiple documented examples serve as integration test cases.

Overall — 100 / 100

Raw 27 / 27 → round(27 / 27 × 100) = 100

Tip

You can run this locally by telling your agent: "review this module against .github/scorecard/SCORECARD.md".


Scored against SCORECARD.md with claude-sonnet-4-5. 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.
@phorcys420 phorcys420 changed the title feat(registry/coder/modules/aws-region): store regions in regions.json and expose availability_zone feat(registry/coder/modules/aws-region): regions.json catalog, default_availability_zone output, optional parameter Sep 21, 2026
@phorcys420

Copy link
Copy Markdown
Member Author

just need to test

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.

1 participant