Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

networking: Allow configurable netnum offsets. #72

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/networking/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ resource "google_compute_route" "egress-inet" {
// which we will use to operate Cloud Run services.
resource "google_compute_subnetwork" "regional" {
for_each = {
for region in var.regions : region => 1 + index(var.regions, region)
for region in var.regions : region => index(var.regions, region)
}

name = "${var.name}-${each.key}"
Expand All @@ -30,5 +30,5 @@ resource "google_compute_subnetwork" "regional" {

network = google_compute_network.this.id
region = each.key
ip_cidr_range = cidrsubnet(var.cidr, 8, each.value)
ip_cidr_range = cidrsubnet(var.cidr, 8, var.netnum_offset + each.value)
}
10 changes: 10 additions & 0 deletions modules/networking/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ variable "regions" {
variable "cidr" {
default = "10.0.0.0/8"
}

variable "netnum_offset" {
type = number
default = 0
validation {
condition = var.netnum_offset >= 0 && var.netnum_offset <= 255
error_message = "value must be between 0 and 255"
}
description = "cidrsubnet netnum offset for the subnet. See https://developer.hashicorp.com/terraform/language/functions/cidrsubnet for more details"
}
Loading