Replace auto-carved private subnets with explicit admin-supplied CIDRs
private_supernet/private_subnet_prefix_length/private_interface_count
(which auto-derived per-router-per-role micro-subnets via cidrsubnet())
are replaced by a single required variable, private_network_cidrs: one
CIDR per shared private network that router VMs get an interface into,
supplied explicitly by the admin - no auto-carving. Each router gets its
own port/IP inside every listed network (cidrhost(cidr, router_index+2)),
closer to the original lan_net design but generalized to N networks and
N routers. network-init.sh.tpl needed no changes - it already matches
interfaces by CIDR membership regardless of whether the CIDR is shared.
Also fixes a testing gap found along the way: `terraform validate` does
not enforce variable validation{} blocks for externally-supplied values
in this terraform version - only `plan`/`apply` do. The test suite now
exercises those validations for real via `terraform plan` against an
isolated, provider-free copy of variables.tf.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011hXR2ftXZZhJ4Y3XuSoR8r
This commit is contained in:
1 parent
5979a9a58b
commit
1ef4b12143
8 files changed
+290
-150
No files matched your search
+15
-23
@@ -36,36 +36,28 @@ variable "router_count" {
|
||||
}
|
||||
}
|
||||
|
||||
variable "private_supernet" {
|
||||
description = "Address pool from which each router's private per-interface subnets are carved (must not overlap router-lan-subnet 10.200.10.0/24)"
|
||||
type = string
|
||||
default = "10.90.0.0/16"
|
||||
}
|
||||
|
||||
variable "private_subnet_prefix_length" {
|
||||
description = "Prefix length of each router's private interface subnet (/29 or /28)"
|
||||
type = number
|
||||
default = 29
|
||||
|
||||
validation {
|
||||
condition = contains([28, 29], var.private_subnet_prefix_length)
|
||||
error_message = "private_subnet_prefix_length must be 28 or 29."
|
||||
}
|
||||
}
|
||||
|
||||
variable "router_availability_zones" {
|
||||
description = "Availability zones to spread router VMs across (cycled via count.index)"
|
||||
type = list(string)
|
||||
default = ["ME1"]
|
||||
}
|
||||
|
||||
variable "private_interface_count" {
|
||||
description = "Number of isolated private interfaces per router VM (in addition to the single public/WAN interface)"
|
||||
type = number
|
||||
default = 2
|
||||
variable "private_network_cidrs" {
|
||||
description = "Explicit CIDR prefix for each private network that router VMs get an interface into. One entry = one shared private network = one private interface per router (list order determines eth1..ethN). Must be supplied explicitly - no auto-carving from a supernet."
|
||||
type = list(string)
|
||||
|
||||
validation {
|
||||
condition = var.private_interface_count >= 1
|
||||
error_message = "private_interface_count must be at least 1."
|
||||
condition = length(var.private_network_cidrs) >= 1
|
||||
error_message = "private_network_cidrs must contain at least one CIDR."
|
||||
}
|
||||
|
||||
validation {
|
||||
condition = alltrue([for c in var.private_network_cidrs : can(cidrhost(c, 0))])
|
||||
error_message = "Every entry in private_network_cidrs must be a valid IPv4 CIDR (e.g. \"10.90.0.0/29\")."
|
||||
}
|
||||
|
||||
validation {
|
||||
condition = length(var.private_network_cidrs) == length(distinct(var.private_network_cidrs))
|
||||
error_message = "private_network_cidrs entries must be unique."
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user