2023-07-05 13:46:44 +00:00
|
|
|
variable "num_networks" {
|
|
|
|
description = "The number of networks to create"
|
|
|
|
default = 5
|
2023-07-05 12:47:14 +00:00
|
|
|
}
|
|
|
|
|
2023-07-05 13:46:44 +00:00
|
|
|
resource "openstack_networking_network_v2" "private_networks" {
|
|
|
|
count = var.num_networks
|
|
|
|
name = format("private_network_%s", count.index+1)
|
2023-07-05 12:47:14 +00:00
|
|
|
admin_state_up = "true"
|
|
|
|
}
|
|
|
|
|
2023-07-05 13:46:44 +00:00
|
|
|
resource "openstack_networking_subnet_v2" "private_networks_sb" {
|
|
|
|
count = var.num_networks
|
|
|
|
name = format("private_network_%s_sb", count.index+1)
|
|
|
|
network_id = element(openstack_networking_network_v2.private_networks.*.id, count.index)
|
|
|
|
cidr = format("10.0.%s.0/24", count.index+1)
|
2023-07-05 12:47:14 +00:00
|
|
|
ip_version = 4
|
|
|
|
allocation_pool {
|
2023-07-05 13:46:44 +00:00
|
|
|
start = format("10.0.%s.101", count.index+1)
|
|
|
|
end = format("10.0.%s.199", count.index+1)
|
2023-07-05 12:47:14 +00:00
|
|
|
}
|
|
|
|
}
|