Skip to content

Commit 8ddc147

Browse files
sdeguchisdeguchi
andauthored
feat: Feature adding top level management group name (#61)
* feat: Adding top level management group name * Fixing unused variables * terraform fmt --------- Co-authored-by: sdeguchi <sdeguchi@microsoft.com>
1 parent 2b3aa80 commit 8ddc147

11 files changed

Lines changed: 116 additions & 35 deletions

File tree

alz/azuredevops/main.tf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ module "resource_names" {
88
}
99

1010
module "architecture_definition" {
11-
count = local.has_architecture_definition ? 1 : 0
12-
source = "../../modules/template_architecture_definition"
13-
starter_module_folder_path = local.starter_root_module_folder_path
14-
architecture_definition_name = local.architecture_definition_name
11+
count = local.has_architecture_definition ? 1 : 0
12+
source = "../../modules/template_architecture_definition"
13+
starter_module_folder_path = local.starter_root_module_folder_path
14+
architecture_definition_name = local.architecture_definition_name
15+
architecture_definition_template_path = var.architecture_definition_template_path
16+
architecture_definition_override_path = var.architecture_definition_override_path
17+
apply_alz_archetypes_via_architecture_definition_template = var.apply_alz_archetypes_via_architecture_definition_template
1518
}
1619

1720
module "files" {

alz/azuredevops/variables.hidden.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,21 @@ variable "root_module_folder_relative_path" {
419419
description = "The root module folder path"
420420
default = "."
421421
}
422+
423+
variable "architecture_definition_template_path" {
424+
type = string
425+
default = ""
426+
description = "The path to the architecture definition template file to use."
427+
}
428+
429+
variable "architecture_definition_override_path" {
430+
type = string
431+
default = ""
432+
description = "The path to the architecture definition file to use instead of the default."
433+
}
434+
435+
variable "apply_alz_archetypes_via_architecture_definition_template" {
436+
type = bool
437+
default = true
438+
description = "Toggles assignment of ALZ policies. True to deploy, otherwise false. (e.g true)"
439+
}

alz/github/main.tf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ module "resource_names" {
88
}
99

1010
module "architecture_definition" {
11-
count = local.has_architecture_definition ? 1 : 0
12-
source = "../../modules/template_architecture_definition"
13-
starter_module_folder_path = local.starter_root_module_folder_path
14-
architecture_definition_name = local.architecture_definition_name
11+
count = local.has_architecture_definition ? 1 : 0
12+
source = "../../modules/template_architecture_definition"
13+
starter_module_folder_path = local.starter_root_module_folder_path
14+
architecture_definition_name = local.architecture_definition_name
15+
architecture_definition_template_path = var.architecture_definition_template_path
16+
architecture_definition_override_path = var.architecture_definition_override_path
17+
apply_alz_archetypes_via_architecture_definition_template = var.apply_alz_archetypes_via_architecture_definition_template
1518
}
1619

1720
module "files" {

alz/github/variables.hidden.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,21 @@ variable "root_module_folder_relative_path" {
419419
description = "The root module folder path"
420420
default = "."
421421
}
422+
423+
variable "architecture_definition_template_path" {
424+
type = string
425+
default = ""
426+
description = "The path to the architecture definition template file to use."
427+
}
428+
429+
variable "architecture_definition_override_path" {
430+
type = string
431+
default = ""
432+
description = "The path to the architecture definition file to use instead of the default."
433+
}
434+
435+
variable "apply_alz_archetypes_via_architecture_definition_template" {
436+
type = bool
437+
default = true
438+
description = "Toggles assignment of ALZ policies. True to deploy, otherwise false. (e.g true)"
439+
}

alz/local/main.tf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ module "resource_names" {
88
}
99

1010
module "architecture_definition" {
11-
count = local.has_architecture_definition ? 1 : 0
12-
source = "../../modules/template_architecture_definition"
13-
starter_module_folder_path = local.starter_root_module_folder_path
14-
architecture_definition_name = local.architecture_definition_name
11+
count = local.has_architecture_definition ? 1 : 0
12+
source = "../../modules/template_architecture_definition"
13+
starter_module_folder_path = local.starter_root_module_folder_path
14+
architecture_definition_name = local.architecture_definition_name
15+
architecture_definition_template_path = var.architecture_definition_template_path
16+
architecture_definition_override_path = var.architecture_definition_override_path
17+
apply_alz_archetypes_via_architecture_definition_template = var.apply_alz_archetypes_via_architecture_definition_template
1518
}
1619

1720
resource "local_file" "architecture_definition_file" {

alz/local/variables.hidden.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,21 @@ variable "root_module_folder_relative_path" {
312312
description = "The root module folder path"
313313
default = "."
314314
}
315+
316+
variable "architecture_definition_template_path" {
317+
type = string
318+
default = ""
319+
description = "The path to the architecture definition template file to use."
320+
}
321+
322+
variable "architecture_definition_override_path" {
323+
type = string
324+
default = ""
325+
description = "The path to the architecture definition file to use instead of the default."
326+
}
327+
328+
variable "apply_alz_archetypes_via_architecture_definition_template" {
329+
type = bool
330+
default = true
331+
description = "Toggles assignment of ALZ policies. True to deploy, otherwise false. (e.g true)"
332+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
data "local_file" "architecture_definition_override_json" {
22
count = local.has_architecture_definition_override ? 1 : 0
3-
filename = local.architecture_definition_override_path
3+
filename = var.architecture_definition_override_path
44
}

modules/template_architecture_definition/locals.tf

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
locals {
22
# Determine template architecture definition inputs from starter module tfvars
3-
starter_module_tfvars = jsondecode(file("${var.starter_module_folder_path}/terraform.tfvars.json"))
4-
default_prefix = local.starter_module_tfvars.default_prefix
5-
default_postfix = local.starter_module_tfvars.default_postfix
6-
enable_alz = local.starter_module_tfvars.apply_alz_archetypes_via_architecture_definition_template
7-
architecture_definition_override_path = local.starter_module_tfvars.architecture_definition_override_path
8-
default_template_file_path = "${path.module}/templates/${var.architecture_definition_name}.alz_architecture_definition.json.tftpl"
9-
template_file_path = local.starter_module_tfvars.architecture_definition_template_path != "" ? local.starter_module_tfvars.architecture_definition_template_path : local.default_template_file_path
3+
starter_module_tfvars = jsondecode(file("${var.starter_module_folder_path}/terraform.tfvars.json"))
4+
default_prefix = local.starter_module_tfvars.default_prefix
5+
default_postfix = local.starter_module_tfvars.default_postfix
6+
top_level_management_group_name = local.starter_module_tfvars.top_level_management_group_name
7+
default_template_file_path = "${path.module}/templates/${var.architecture_definition_name}.alz_architecture_definition.json.tftpl"
8+
template_file_path = var.architecture_definition_template_path != "" ? var.architecture_definition_template_path : local.default_template_file_path
109

1110
# Customer has provided a custom architecture definition
12-
has_architecture_definition_override = local.architecture_definition_override_path != ""
11+
has_architecture_definition_override = var.architecture_definition_override_path != ""
1312

1413
# ALZ archetypes
1514
alz_root = ["\"root\""]
@@ -24,21 +23,22 @@ locals {
2423
alz_identity = ["\"identity\""]
2524

2625
# management group layered archetypes
27-
root = local.enable_alz ? local.alz_root : []
28-
platform = local.enable_alz ? local.alz_platform : []
29-
landing_zone = local.enable_alz ? local.alz_landing_zone : []
30-
decommissioned = local.enable_alz ? local.alz_decommissioned : []
31-
sandboxes = local.enable_alz ? local.alz_sandboxes : []
32-
corp = local.enable_alz ? local.alz_corp : []
33-
online = local.enable_alz ? local.alz_online : []
34-
management = local.enable_alz ? local.alz_management : []
35-
connectivity = local.enable_alz ? local.alz_connectivity : []
36-
identity = local.enable_alz ? local.alz_identity : []
37-
confidential_corp = local.enable_alz ? local.alz_corp : []
38-
confidential_online = local.enable_alz ? local.alz_online : []
26+
root = var.apply_alz_archetypes_via_architecture_definition_template ? local.alz_root : []
27+
platform = var.apply_alz_archetypes_via_architecture_definition_template ? local.alz_platform : []
28+
landing_zone = var.apply_alz_archetypes_via_architecture_definition_template ? local.alz_landing_zone : []
29+
decommissioned = var.apply_alz_archetypes_via_architecture_definition_template ? local.alz_decommissioned : []
30+
sandboxes = var.apply_alz_archetypes_via_architecture_definition_template ? local.alz_sandboxes : []
31+
corp = var.apply_alz_archetypes_via_architecture_definition_template ? local.alz_corp : []
32+
online = var.apply_alz_archetypes_via_architecture_definition_template ? local.alz_online : []
33+
management = var.apply_alz_archetypes_via_architecture_definition_template ? local.alz_management : []
34+
connectivity = var.apply_alz_archetypes_via_architecture_definition_template ? local.alz_connectivity : []
35+
identity = var.apply_alz_archetypes_via_architecture_definition_template ? local.alz_identity : []
36+
confidential_corp = var.apply_alz_archetypes_via_architecture_definition_template ? local.alz_corp : []
37+
confidential_online = var.apply_alz_archetypes_via_architecture_definition_template ? local.alz_online : []
3938

4039
template_vars = {
4140
architecture_definition_name = var.architecture_definition_name
41+
top_level_management_group_name = local.top_level_management_group_name
4242
root_management_group_id = "${local.default_prefix}${local.default_postfix}"
4343
platform_management_group_id = "${local.default_prefix}-platform${local.default_postfix}"
4444
landing_zone_management_group_id = "${local.default_prefix}-landingzones${local.default_postfix}"

modules/template_architecture_definition/templates/fsi.alz_architecture_definition.json.tftpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"management_groups": [
44
{
55
"archetypes": [${root_archetypes}, "fsi_root", "tr_01_logging", "re_01_zonal_residency", "so_04_cmk", "so_01_data_residency"],
6-
"display_name": "FSI Landing Zone",
6+
"display_name": "${top_level_management_group_name}",
77
"exists": false,
88
"id": "${root_management_group_id}",
99
"parent_id": null

modules/template_architecture_definition/templates/slz.alz_architecture_definition.json.tftpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"management_groups": [
44
{
55
"archetypes": [${root_archetypes}, "global"],
6-
"display_name": "Sovereign Landing Zone",
6+
"display_name": "${top_level_management_group_name}",
77
"exists": false,
88
"id": "${root_management_group_id}",
99
"parent_id": null

0 commit comments

Comments
 (0)