Add CIDR validation to allowed_cidrs across all six core tier modules#12
Open
dmchaledev wants to merge 1 commit into
Open
Add CIDR validation to allowed_cidrs across all six core tier modules#12dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
Without this, a typo like "10.0.0/8" (missing octet) passes terraform
validate and tflint but fails with a cryptic provider error at apply time.
The new validation block calls can(cidrhost(c, 0)) on each element, which
rejects malformed CIDRs at terraform plan with a clear error message.
Applied consistently to all three tiers on both clouds:
modules/single-vm/{aws,azure}
modules/ha-hot-hot/{aws,azure}
modules/unlimited-scale/{aws,azure}
The product-prefixed wrappers forward var.allowed_cidrs directly to the
core module, so the validation fires regardless of which public API module
the caller uses.
https://claude.ai/code/session_01L9uXLeu5oZTJuEtwar9ckz
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 required input on every tier module, but it accepted anylist(string). A one-character typo —"10.0.0/8"instead of"10.0.0.0/8"— passesterraform validateandtflintwith no complaint, then fails atterraform applywith a cryptic AWS/Azure provider error deep in the resource graph. The operator has to read a provider stack trace to discover the input was malformed.Fix
Add a
validationblock toallowed_cidrsin all six core tier modules using the standardcan(cidrhost(c, 0))idiom, which Terraform evaluates atplantime before any API calls:can(cidrhost(c, 0))validates both IPv4 and IPv6 CIDR notation. It accepts0.0.0.0/0(internet ingress opt-in) and rejects anything that isn't parseable as a network prefix.Scope
Changed files — one per core tier module, both clouds:
single-vm/awsmodules/single-vm/aws/variables.tfsingle-vm/azuremodules/single-vm/azure/variables.tfha-hot-hot/awsmodules/ha-hot-hot/aws/variables.tfha-hot-hot/azuremodules/ha-hot-hot/azure/variables.tfunlimited-scale/awsmodules/unlimited-scale/aws/variables.tfunlimited-scale/azuremodules/unlimited-scale/azure/variables.tfThe twelve product-prefixed wrappers (
asm-aws-single,sat-azure-ha, etc.) forwardvar.allowed_cidrsdirectly to the core module, so the validation fires for callers of the public API modules without any wrapper changes.Impact
terraform planwith"Each entry in allowed_cidrs must be a valid CIDR block (e.g. 10.0.0.0/8)."instead of atapplywith a provider error.unlimited-scale/azureandha-hot-hot/azurevariables also received a missingdescriptionfield to match the style of the other modules.Test plan
terraform validatepasses on all six modules (CI gate)tflintpasses (CI gate)terraform planwithallowed_cidrs = ["10.0.0/8"]produces the new validation error message before any provider callsGenerated by Claude Code