Skip to content

feat: add per-environment AWS region configuration - #396

Merged
mwendigg merged 1 commit into
dreadnode:mainfrom
l50:upstream/per-environment-aws-region
Aug 3, 2026
Merged

feat: add per-environment AWS region configuration#396
mwendigg merged 1 commit into
dreadnode:mainfrom
l50:upstream/per-environment-aws-region

Conversation

@l50

@l50 l50 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Key Changes:

  • Introduced per-environment region declarations so each lab resolves to the region it is actually deployed in
  • Established a clear region resolution precedence: explicit --region/DREADGOAD_REGION override, then the active environment's region, then the top-level fallback
  • Added a guard that fails inventory sync when no instances are found, preventing a false "all values current" success from querying the wrong region

Added:

  • Per-environment region field - Added Region to EnvironmentConfig in config.go so each environment maps to the correct infra/{deployment}/{env}/{region}/ tree
  • Region override mechanism - Introduced SetRegionOverride and a regionOverride field so an explicit --region flag outranks config-file values that viper would otherwise collapse into the same key; the root command wires this up from PersistentPreRunE in root.go, and DREADGOAD_REGION is consulted in Get() when no flag is present
  • Empty-instance guard - runInventorySync in inventory.go now returns an actionable error (naming the env and region) when discovery finds no instances, since falling through would silently report a false success
  • Region documentation - Added a "Region" section to docs/cli.md explaining resolution order and the relationship between region and lab deployment
  • Test coverage - Added table-driven tests for ResolveRegion covering environment precedence and fallback, plus TestGetRegionOverridePrecedence verifying --region beats DREADGOAD_REGION

Changed:

  • Region resolution logic - Reworked ResolveRegion in config.go to check the override, then the active environment's region, then the global region, with an error message that names the specific environments.<env>.region key to set
  • Trace output - Updated TraceConfig in trace.go to report the effective region the CLI will use and its source (e.g. config file (environments.<env>.region)) rather than the raw top-level key
  • Reset behavior - Reset() now clears regionOverride so tests start from a clean state
  • Documentation of the top-level region - Reframed the region key in docs/cli.md as a fallback for environments that don't declare their own, and added region entries to the example staging, prod, and test environments

@dreadnode-renovate-bot dreadnode-renovate-bot Bot added the area/docs Changes made to documentation label Aug 3, 2026
**Added:**

- Per-environment `region` field to `EnvironmentConfig`, since each lab is deployed to its own region and must match the `infra/{deployment}/{env}/{region}/` tree - cli/internal/config/config.go
- `SetRegionOverride` and an internal `regionOverride` field to carry a region supplied explicitly via `--region` or `DREADGOAD_REGION` so it outranks per-environment config, which viper cannot express on its own - cli/internal/config/config.go
- `--region` flag handling in the root command's `PersistentPreRunE`, passing an explicit flag value through `SetRegionOverride` - cli/cmd/root.go
- Empty-inventory guard in `runInventorySync` that fails with a region-aware error rather than falsely reporting "all values are current" - cli/cmd/inventory.go
- Table-driven `TestResolveRegion` cases and `TestGetRegionOverridePrecedence` covering environment, global, override, and env-var precedence - cli/internal/config/config_test.go
- Installation section and a Region section documenting resolution order and infra-tree alignment - docs/cli.md

**Changed:**

- `ResolveRegion` now resolves in precedence order (override, active environment region, top-level fallback) and returns an error naming the environment key to set - cli/internal/config/config.go
- `Reset` clears the `regionOverride` package variable - cli/internal/config/config.go
- Config trace reports the effective resolved region and its source instead of the raw top-level key - cli/internal/config/trace.go
- Sample config comments to describe `region` as a per-environment lab property with a top-level fallback - docs/cli.md
@l50
l50 force-pushed the upstream/per-environment-aws-region branch from 1e1058b to aa8961c Compare August 3, 2026 20:06
@mwendigg
mwendigg added this pull request to the merge queue Aug 3, 2026
Merged via the queue into dreadnode:main with commit 757f2f5 Aug 3, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Changes made to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants