feat: validate CIDR format on allowed_cidrs in all tier modules#15
Open
dmchaledev wants to merge 1 commit into
Open
feat: validate CIDR format on allowed_cidrs in all tier modules#15dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
Add a validation block to the allowed_cidrs variable in all six core tier modules (single-vm, ha-hot-hot, unlimited-scale × AWS + Azure). The check uses can(cidrhost(cidr, 0)) which is the idiomatic Terraform approach and catches malformed CIDRs at plan time rather than at apply. No breaking change — any value that was valid before is still valid; the validation only rejects input that would have failed downstream anyway. https://claude.ai/code/session_01RMbrNRRsPYTr3SbUBbvJrM
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.
Problem
allowed_cidrsis a security-critical input — it directly controls which source ranges reach ALBs and VMs on port 443. However the variable had no format validation in any of the six core tier modules. A typo like10.0.0.999/8ornot-a-cidrwould only surface as an obscure AWS/Azure API error atterraform apply, not atterraform validateorterraform plan.Fix
Add a
validationblock toallowed_cidrsin all six tier modules:The check uses the idiomatic Terraform pattern:
can(cidrhost(cidr, 0))handles both IPv4 and IPv6, rejects malformed input immediately, and is zero-dependency (pure HCL).Impact
Test plan
terraform validatepasses in each of the six changed modulestflintpasses with no new findingscheckov/trivygreen (no new policy findings)"not-a-cidr") is rejected at plan time with the new error messagehttps://claude.ai/code/session_01RMbrNRRsPYTr3SbUBbvJrM
Generated by Claude Code