Skip to content

Commit

Permalink
Add the ability to prefix name and description of IPAM scope and pools (
Browse files Browse the repository at this point in the history
  • Loading branch information
avnes authored Sep 11, 2024
1 parent 64dc1de commit 152bbd1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 7 additions & 7 deletions network/ipam/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ module "ipam" {
module "ipam_scope" {
source = "../../_sub/network/ipam-scope"
ipam_id = module.ipam.id
scope_name = var.ipam_scope_name
scope_name = length(var.ipam_prefix) > 0 ? "${var.ipam_prefix}-${var.ipam_scope_name}" : var.ipam_scope_name
tags = var.tags
}

module "main_pool" {
source = "../../_sub/network/ipam-pool"
scope_id = module.ipam_scope.id
pool = {
name = "main"
name = length(var.ipam_prefix) > 0 ? "${var.ipam_prefix}-main" : "main"
cidr = var.ipam_pools["main"].cidr
}
cascade = var.ipam_pools_cascade
Expand All @@ -28,7 +28,7 @@ module "platform_pool" {
source = "../../_sub/network/ipam-pool"
scope_id = module.ipam_scope.id
pool = {
name = "platform"
name = length(var.ipam_prefix) > 0 ? "${var.ipam_prefix}-platform" : "platform"
cidr = var.ipam_pools["platform"].cidr
}
source_ipam_pool_id = module.main_pool.id
Expand All @@ -40,7 +40,7 @@ module "capabilities_pool" {
source = "../../_sub/network/ipam-pool"
scope_id = module.ipam_scope.id
pool = {
name = "capabilities"
name = length(var.ipam_prefix) > 0 ? "${var.ipam_prefix}-capabilities" : "capabilities"
cidr = var.ipam_pools["capabilities"].cidr
}
source_ipam_pool_id = module.main_pool.id
Expand All @@ -52,7 +52,7 @@ module "unused_pool" {
source = "../../_sub/network/ipam-pool"
scope_id = module.ipam_scope.id
pool = {
name = "unused"
name = length(var.ipam_prefix) > 0 ? "${var.ipam_prefix}-unused" : "unused"
cidr = var.ipam_pools["unused"].cidr
}
source_ipam_pool_id = module.main_pool.id
Expand All @@ -65,7 +65,7 @@ module "regional_platform_pools" {
for_each = var.ipam_pools["platform"].sub_pools
scope_id = module.ipam_scope.id
pool = {
name = "platform-${each.key}"
name = length(var.ipam_prefix) > 0 ? "${var.ipam_prefix}-platform-${each.key}" : "platform-${each.key}"
cidr = each.value.cidr
locale = each.key
}
Expand All @@ -78,7 +78,7 @@ module "regional_capabilities_pools" {
for_each = var.ipam_pools["capabilities"].sub_pools
scope_id = module.ipam_scope.id
pool = {
name = "capabilities-${each.key}"
name = length(var.ipam_prefix) > 0 ? "${var.ipam_prefix}-capabilities-${each.key}" : "capabilities-${each.key}"
cidr = each.value.cidr
locale = each.key
}
Expand Down
6 changes: 6 additions & 0 deletions network/ipam/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ variable "ipam_pools" {
EOF
}

variable "ipam_prefix" {
type = string
description = "Optional prefix to use for the IPAM scope and pools."
default = ""
}

variable "tags" {
type = map(string)
description = "A map of tags to apply to all the resources deployed by the module"
Expand Down

0 comments on commit 152bbd1

Please sign in to comment.