fix(2-networking-a-fedramp): validate proxy_subnets and tenant subnets up front - #216
Open
scottonix wants to merge 1 commit into
Open
fix(2-networking-a-fedramp): validate proxy_subnets and tenant subnets up front#216scottonix wants to merge 1 commit into
scottonix wants to merge 1 commit into
Conversation
…s up front
Two inputs the stage documents as optional are in fact required, and a plan
that omits them dies with 'Invalid index' deep inside the module tree:
- proxy_subnets defaults to {} but branch-net-envs.tf indexes it with each
environment key when it creates the spoke's proxy-only subnet.
- every environment needs a subnet under subnets[lower(<env>)] with a
non-null tenant in regions.primary: connectivity-tests.tf, nva.tf and
outputs.tf all take the first such subnet with [0] and index the spoke's
subnet map with it.
Add validation blocks on both variables (they may reference envs_folders and
regions since Terraform 1.9, and the modules already require 1.10.2) so the
plan fails immediately with a message that names the missing input, and say
in the proxy_subnets description that one entry per environment is required.
Signed-off-by: Scott McDonald <scott.mcdonald@onixnet.com>
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.
Description
Two inputs of
fast/stages-aw/2-networking-a-fedrampread as optional but are required, and a plan that omits either one fails withInvalid indexdeep inside the module tree rather than at the input:proxy_subnetsdefaults to{}, butbranch-net-envs.tf:109indexes it with each environment key (var.proxy_subnets[each.key]) to create the spoke's proxy-only subnet.subnets[lower(<env>)]with a non-nulltenantinregions.primary:connectivity-tests.tf:79,nva.tf:31andoutputs.tf:23all take the first such subnet with[...][0]and use it to index the spoke's subnet map. With no tenant subnet thetry()returns an empty list and[0]fails; with the first tenant subnet in another region the map lookup fails.This adds a
validationblock to each variable so the plan stops immediately with a message that names the missing input, and states in theproxy_subnetsdescription that one entry per environment is required. Validation blocks may reference other variables since Terraform 1.9, and the shared modules already require>= 1.10.2. No resource or output changes; a configuration that planned before plans identically now.Making both inputs genuinely optional (no proxy-only subnet, no connectivity test address for an environment without one) would be a larger change touching three files and the stage outputs consumed by later stages; happy to do that as a follow-up if that is the preferred direction.
Type of Change
Deployment & Compliance Impact
Checklist
Code Quality & Reusability
modules/orfast/can be leveraged for this change.documentation/naming-convention.md.Documentation
README.mdof the modified module or blueprint. (Variable description updated; the README variables table is tfdoc-generated.)Security
Testing
Testing Performed
Terraform 1.10.5,
terraform fmt -checkclean,terraform validatepasses. Plans with placeholder inputs (-refresh=false, invalid credentials; one environmentProd, one tenantten-1):main(df47667)proxy_subnetsand a tenant subnet inus-east4providedproxy_subnetsomittedError: Invalid indexonbranch-net-envs.tfline 109 (var.proxy_subnets is empty map of string)Error: Invalid value for variableonproxy_subnets: proxy_subnets needs an entry for every key of envs_folders …tenantInvalid indexonbranch-net-envs.tf:221,Invalid template interpolation valueon:222,Invalid indexonconnectivity-tests.tf:79and onnva.tf:31Error: Invalid value for variableonsubnets: Every environment in envs_folders needs a subnet list … whose first subnet with a non-null tenant is in regions.primary …Both failure modes were first hit on a live deployment of this stage (each cost a failed Cloud Build run before the cause was found in the module code).