Skip to content

Commit

Permalink
Try fix layer logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredfholgate committed Nov 7, 2023
1 parent 04b5d9e commit accf2e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
26 changes: 20 additions & 6 deletions templates/complete_modular/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ locals {
management_groups = local.initial_config.management_groups

management_groups_layer_1 = { for k, v in local.management_groups : k => v if v.parent_id == local.tenant_root_management_group_id }
management_groups_layer_2 = { for k, v in local.management_groups : k => v if contains(keys(local.management_groups_layer_1), v.parent_id) }
management_groups_layer_3 = { for k, v in local.management_groups : k => v if contains(keys(local.management_groups_layer_2), v.parent_id) }
management_groups_layer_4 = { for k, v in local.management_groups : k => v if contains(keys(local.management_groups_layer_3), v.parent_id) }
management_groups_layer_5 = { for k, v in local.management_groups : k => v if contains(keys(local.management_groups_layer_4), v.parent_id) }
management_groups_layer_6 = { for k, v in local.management_groups : k => v if contains(keys(local.management_groups_layer_5), v.parent_id) }
management_groups_layer_7 = { for k, v in local.management_groups : k => v if contains(keys(local.management_groups_layer_6), v.parent_id) }
management_groups_layer_2 = { for k, v in local.management_groups : k => v if contains(values(local.management_groups_layer_1)[*].id, v.parent_id) }
management_groups_layer_3 = { for k, v in local.management_groups : k => v if contains(values(local.management_groups_layer_2)[*].id, v.parent_id) }
management_groups_layer_4 = { for k, v in local.management_groups : k => v if contains(values(local.management_groups_layer_3)[*].id, v.parent_id) }
management_groups_layer_5 = { for k, v in local.management_groups : k => v if contains(values(local.management_groups_layer_4)[*].id, v.parent_id) }
management_groups_layer_6 = { for k, v in local.management_groups : k => v if contains(values(local.management_groups_layer_5)[*].id, v.parent_id) }
management_groups_layer_7 = { for k, v in local.management_groups : k => v if contains(values(local.management_groups_layer_6)[*].id, v.parent_id) }



connectivity = local.initial_config.connectivity

Expand All @@ -42,3 +44,15 @@ locals {
)
}
}

output "test" {
value = {
management_groups_layer_1 = local.management_groups_layer_1
management_groups_layer_2 = local.management_groups_layer_2
management_groups_layer_3 = local.management_groups_layer_3
management_groups_layer_4 = local.management_groups_layer_4
management_groups_layer_5 = local.management_groups_layer_5
management_groups_layer_6 = local.management_groups_layer_6
management_groups_layer_7 = local.management_groups_layer_7
}
}
4 changes: 0 additions & 4 deletions templates/complete_modular/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ module "management_resources" {
resource_group_name = try(local.management.resource_group_name, "")
}

output "test" {
value = local.management_groups
}

module "hub_networking" {
source = "Azure/hubnetworking/azurerm"
version = "~> 1.1.0"
Expand Down

0 comments on commit accf2e3

Please sign in to comment.