feat: add per-environment AWS region configuration - #396
Merged
Conversation
**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
force-pushed
the
upstream/per-environment-aws-region
branch
from
August 3, 2026 20:06
1e1058b to
aa8961c
Compare
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.
Key Changes:
--region/DREADGOAD_REGIONoverride, then the active environment's region, then the top-level fallbackAdded:
RegiontoEnvironmentConfiginconfig.goso each environment maps to the correctinfra/{deployment}/{env}/{region}/treeSetRegionOverrideand aregionOverridefield so an explicit--regionflag outranks config-file values that viper would otherwise collapse into the same key; the root command wires this up fromPersistentPreRunEinroot.go, andDREADGOAD_REGIONis consulted inGet()when no flag is presentrunInventorySyncininventory.gonow returns an actionable error (naming the env and region) when discovery finds no instances, since falling through would silently report a false successdocs/cli.mdexplaining resolution order and the relationship between region and lab deploymentResolveRegioncovering environment precedence and fallback, plusTestGetRegionOverridePrecedenceverifying--regionbeatsDREADGOAD_REGIONChanged:
ResolveRegioninconfig.goto check the override, then the active environment's region, then the global region, with an error message that names the specificenvironments.<env>.regionkey to setTraceConfigintrace.goto report the effective region the CLI will use and its source (e.g.config file (environments.<env>.region)) rather than the raw top-level keyReset()now clearsregionOverrideso tests start from a clean stateregionkey indocs/cli.mdas a fallback for environments that don't declare their own, and added region entries to the examplestaging,prod, andtestenvironments