Add private cidr

This commit is contained in:
Greyscale 2024-11-27 15:28:10 +01:00
parent a5f6e7bb17
commit c2aa4919bd
Signed by: grey
GPG key ID: DDB392AE64B32D89
3 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,15 @@
resource "random_integer" "upper_mid_byte" {
min = 18
max = 31
}
resource "random_integer" "lower_mid_byte" {
min = 10
max = 254
}
locals {
// Generate a subnet
subnet = "172.${random_integer.upper_mid_byte.result}.${random_integer.lower_mid_byte.result}.0/24"
// Calculate the gateway from the subnet
gateway = cidrhost(local.subnet, 1)
}

View file

@ -0,0 +1,6 @@
output "subnet" {
value = local.subnet
}
output "gateway" {
value = local.gateway
}

View file

@ -0,0 +1,12 @@
terraform {
required_version = "~> 1.6"
required_providers {
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
}
}