Skip to content

Commit d4c318f

Browse files
committed
feat: accelerator permission flattening
1 parent 6d8bb28 commit d4c318f

13 files changed

Lines changed: 355 additions & 477 deletions

File tree

alz/azuredevops/main.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,17 @@ module "azure" {
5959
container_registry_dockerfile_name = var.agent_container_image_dockerfile
6060
container_registry_dockerfile_repository_folder_url = local.agent_container_instance_dockerfile_url
6161
custom_role_definitions = var.iac_type == "terraform" ? local.custom_role_definitions_terraform : (var.iac_type == "bicep" ? local.custom_role_definitions_bicep : local.custom_role_definitions_bicep_classic)
62-
role_assignments = var.iac_type == "terraform" ? var.role_assignments_terraform : var.role_assignments_bicep
62+
role_assignments = var.iac_type == "terraform" ? var.role_assignments_terraform : (var.iac_type == "bicep" ? var.role_assignments_bicep : var.role_assignments_bicep_classic)
6363
storage_account_blob_soft_delete_enabled = var.storage_account_blob_soft_delete_enabled
6464
storage_account_blob_soft_delete_retention_days = var.storage_account_blob_soft_delete_retention_days
6565
storage_account_blob_versioning_enabled = var.storage_account_blob_versioning_enabled
6666
storage_account_container_soft_delete_enabled = var.storage_account_container_soft_delete_enabled
6767
storage_account_container_soft_delete_retention_days = var.storage_account_container_soft_delete_retention_days
6868
tenant_role_assignment_enabled = var.iac_type == "bicep" && var.bicep_tenant_role_assignment_enabled
6969
tenant_role_assignment_role_definition_name = var.bicep_tenant_role_assignment_role_definition_name
70+
intermediate_root_management_group_creation_enabled = var.iac_type != "bicep-classic"
71+
intermediate_root_management_group_id = module.file_manipulation.intermediate_root_management_group_id
72+
intermediate_root_management_group_display_name = module.file_manipulation.intermediate_root_management_group_display_name
7073
}
7174

7275
module "azure_devops" {
@@ -120,4 +123,5 @@ module "file_manipulation" {
120123
agent_pool_or_runner_configuration = local.agent_pool_or_runner_configuration
121124
pipeline_files_directory_path = local.pipeline_files_directory_path
122125
pipeline_template_files_directory_path = local.pipeline_template_files_directory_path
126+
terraform_architecture_file_path = var.terraform_architecture_file_path
123127
}

alz/azuredevops/variables.tf

Lines changed: 67 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,7 @@ variable "custom_role_definitions_terraform" {
593593
- `actions` (list(string)) - Allowed Azure actions
594594
- `not_actions` (list(string)) - Denied Azure actions
595595
596-
Default includes 4 predefined roles:
597-
- `alz_management_group_contributor` - Manage management group hierarchy and governance
598-
- `alz_management_group_reader` - Read management group structure and validate deployments
599-
- `alz_subscription_owner` - Full access to platform subscriptions
600-
- `alz_subscription_reader` - Read/write access for platform subscription resources
596+
Default is empty, meaning no custom roles are created.
601597
602598
See default value for complete role action definitions.
603599
EOT
@@ -609,89 +605,7 @@ variable "custom_role_definitions_terraform" {
609605
not_actions = list(string)
610606
})
611607
}))
612-
default = {
613-
alz_management_group_contributor = {
614-
name = "Azure Landing Zones Management Group Contributor ({{service_name}}-{{environment_name}})"
615-
description = "This is a custom role created by the Azure Landing Zones Accelerator for Writing the Management Group Structure."
616-
permissions = {
617-
actions = [
618-
"Microsoft.Management/managementGroups/delete",
619-
"Microsoft.Management/managementGroups/read",
620-
"Microsoft.Management/managementGroups/subscriptions/delete",
621-
"Microsoft.Management/managementGroups/subscriptions/write",
622-
"Microsoft.Management/managementGroups/settings/read",
623-
"Microsoft.Management/managementGroups/settings/write",
624-
"Microsoft.Management/managementGroups/settings/delete",
625-
"Microsoft.Management/managementGroups/write",
626-
"Microsoft.Management/managementGroups/subscriptions/read",
627-
"Microsoft.Authorization/policyDefinitions/write",
628-
"Microsoft.Authorization/policySetDefinitions/write",
629-
"Microsoft.Authorization/policyAssignments/write",
630-
"Microsoft.Authorization/roleDefinitions/write",
631-
"Microsoft.Authorization/*/read",
632-
"Microsoft.Authorization/roleAssignments/write",
633-
"Microsoft.Authorization/roleAssignments/delete",
634-
"Microsoft.Insights/diagnosticSettings/write"
635-
]
636-
not_actions = []
637-
}
638-
}
639-
alz_management_group_reader = {
640-
name = "Azure Landing Zones Management Group Reader ({{service_name}}-{{environment_name}})"
641-
description = "This is a custom role created by the Azure Landing Zones Accelerator for Reading the Management Group Structure."
642-
permissions = {
643-
actions = [
644-
"Microsoft.Management/managementGroups/read",
645-
"Microsoft.Management/managementGroups/subscriptions/read",
646-
"Microsoft.Management/managementGroups/settings/read",
647-
"Microsoft.Authorization/*/read",
648-
"Microsoft.Authorization/policyDefinitions/write",
649-
"Microsoft.Authorization/policySetDefinitions/write",
650-
"Microsoft.Authorization/roleDefinitions/write",
651-
"Microsoft.Authorization/policyAssignments/write",
652-
"Microsoft.Insights/diagnosticSettings/write",
653-
"Microsoft.Insights/diagnosticSettings/read",
654-
"Microsoft.Resources/deployments/whatIf/action",
655-
"Microsoft.Resources/deployments/write",
656-
"Microsoft.Resources/deploymentStacks/read",
657-
"Microsoft.Resources/deploymentStacks/validate/action"
658-
]
659-
not_actions = []
660-
}
661-
}
662-
alz_subscription_owner = {
663-
name = "Azure Landing Zones Subscription Owner ({{service_name}}-{{environment_name}})"
664-
description = "This is a custom role created by the Azure Landing Zones Accelerator for Writing in platform subscriptions."
665-
permissions = {
666-
actions = [
667-
"*"
668-
]
669-
not_actions = []
670-
}
671-
}
672-
alz_subscription_reader = {
673-
name = "Azure Landing Zones Subscription Reader ({{service_name}}-{{environment_name}})"
674-
description = "This is a custom role created by the Azure Landing Zones Accelerator for Reading the platform subscriptions."
675-
permissions = {
676-
actions = [
677-
"*/read",
678-
"Microsoft.Resources/subscriptions/resourceGroups/write",
679-
"Microsoft.ManagedIdentity/userAssignedIdentities/write",
680-
"Microsoft.Automation/automationAccounts/write",
681-
"Microsoft.OperationalInsights/workspaces/write",
682-
"Microsoft.OperationalInsights/workspaces/linkedServices/write",
683-
"Microsoft.OperationsManagement/solutions/write",
684-
"Microsoft.Insights/dataCollectionRules/write",
685-
"Microsoft.Authorization/locks/write",
686-
"Microsoft.Network/*/write",
687-
"Microsoft.Resources/deployments/whatIf/action",
688-
"Microsoft.Resources/deployments/write",
689-
"Microsoft.SecurityInsights/onboardingStates/write"
690-
]
691-
not_actions = []
692-
}
693-
}
694-
}
608+
default = {}
695609
}
696610

697611
variable "custom_role_definitions_bicep" {
@@ -707,11 +621,8 @@ variable "custom_role_definitions_bicep" {
707621
- `actions` (list(string)) - Allowed Azure actions
708622
- `not_actions` (list(string)) - Denied Azure actions
709623
710-
Default includes 4 predefined roles:
711-
- `alz_management_group_contributor` - Manage management group hierarchy and governance
712-
- `alz_management_group_reader` - Run Bicep What-If validations (requires --validation-level providerNoRbac flag)
713-
- `alz_subscription_owner` - Full access to platform subscriptions
714-
- `alz_subscription_reader` - Run Bicep What-If for subscription deployments
624+
Default includes 1 predefined roles:
625+
- `alz_reader` - Run Bicep What-If validations (requires --validation-level providerNoRbac flag)s
715626
716627
See default value for complete role action definitions.
717628
EOT
@@ -724,25 +635,7 @@ variable "custom_role_definitions_bicep" {
724635
})
725636
}))
726637
default = {
727-
alz_management_group_contributor = {
728-
name = "Azure Landing Zones Management Group Contributor ({{service_name}}-{{environment_name}})"
729-
description = "This is a custom role created by the Azure Landing Zones Accelerator for creating and managing the Management Group hierarchy and its associated governance resources such as policy, RBAC etc..."
730-
permissions = {
731-
actions = [
732-
"*/read",
733-
"Microsoft.Management/*",
734-
"Microsoft.Authorization/*",
735-
"Microsoft.Resources/*",
736-
"Microsoft.Support/*",
737-
"Microsoft.Insights/diagnosticSettings/*"
738-
]
739-
not_actions = [
740-
"Microsoft.Resources/subscriptions/resourceGroups/write",
741-
"Microsoft.Resources/subscriptions/resourceGroups/delete"
742-
]
743-
}
744-
}
745-
alz_management_group_reader = {
638+
alz_reader = {
746639
name = "Azure Landing Zones Management Group What If ({{service_name}}-{{environment_name}})"
747640
description = "This is a custom role created by the Azure Landing Zones Accelerator for running Bicep What If for the Management Group hierarchy and its associated governance resources such as policy, RBAC etc... You must use the `--validation-level providerNoRbac` (Az CLI 2.75.0 or later) or `-ValidationLevel providerNoRbac` (Az PowerShell 13.4.0 or later (Az.Resources 7.10.0 or later)) flag when running Bicep What If with this role."
748641
permissions = {
@@ -756,30 +649,6 @@ variable "custom_role_definitions_bicep" {
756649
not_actions = []
757650
}
758651
}
759-
alz_subscription_owner = {
760-
name = "Azure Landing Zones Subscription Owner ({{service_name}}-{{environment_name}})"
761-
description = "This is a custom role created by the Azure Landing Zones Accelerator for Writing in platform subscriptions."
762-
permissions = {
763-
actions = [
764-
"*"
765-
]
766-
not_actions = []
767-
}
768-
}
769-
alz_subscription_reader = {
770-
name = "Azure Landing Zones Subscription What If ({{service_name}}-{{environment_name}})"
771-
description = "This is a custom role created by the Azure Landing Zones Accelerator for running Bicep What If for the Management Group hierarchy and its associated governance resources such as policy, RBAC etc... You must use the `--validation-level providerNoRbac` (Az CLI 2.75.0 or later) or `-ValidationLevel providerNoRbac` (Az PowerShell 13.4.0 or later (Az.Resources 7.10.0 or later)) flag when running Bicep What If with this role."
772-
permissions = {
773-
actions = [
774-
"*/read",
775-
"Microsoft.Resources/deployments/whatIf/action",
776-
"Microsoft.Resources/deployments/validate/action",
777-
"Microsoft.Resources/subscriptions/operationResults/read",
778-
"Microsoft.Management/operationResults/*/read"
779-
]
780-
not_actions = []
781-
}
782-
}
783652
}
784653
}
785654

@@ -909,50 +778,83 @@ variable "role_assignments_terraform" {
909778
Map of role assignment configurations where:
910779
- **Key**: Assignment identifier (e.g., 'plan_management_group')
911780
- **Value**: Object containing:
781+
- `built_in_role_definition_name` (string) - Name of built-in role (e.g., 'Owner', 'Contributor')
912782
- `custom_role_definition_key` (string) - Key from custom_role_definitions_terraform
913783
- `user_assigned_managed_identity_key` (string) - Managed identity key ('plan' or 'apply')
914784
- `scope` (string) - Assignment scope ('management_group' or 'subscription')
915785
916-
Default includes 4 assignments:
917-
- Plan and apply access for management group operations
918-
- Plan and apply access for subscription operations
786+
Default includes 2 assignments:
787+
- Plan and apply access
788+
919789
EOT
920790
type = map(object({
921-
custom_role_definition_key = string
791+
built_in_role_definition_name = optional(string)
792+
custom_role_definition_key = optional(string)
922793
user_assigned_managed_identity_key = string
923794
scope = string
924795
}))
925796
default = {
926-
plan_management_group = {
927-
custom_role_definition_key = "alz_management_group_reader"
797+
plan = {
798+
built_in_role_definition_name = "Reader"
928799
user_assigned_managed_identity_key = "plan"
929800
scope = "management_group"
930801
}
931-
apply_management_group = {
932-
custom_role_definition_key = "alz_management_group_contributor"
802+
apply = {
803+
built_in_role_definition_name = "Owner"
933804
user_assigned_managed_identity_key = "apply"
934805
scope = "management_group"
935806
}
936-
plan_subscription = {
937-
custom_role_definition_key = "alz_subscription_reader"
807+
}
808+
}
809+
810+
variable "role_assignments_bicep" {
811+
description = <<-EOT
812+
**(Optional)** RBAC role assignments for Bicep-based deployments.
813+
814+
Map of role assignment configurations where:
815+
- **Key**: Assignment identifier (e.g., 'plan_management_group')
816+
- **Value**: Object containing:
817+
- `built_in_role_definition_name` (string) - Name of built-in role (e.g., 'Owner', 'Contributor')
818+
- `custom_role_definition_key` (string) - Key from custom_role_definitions_bicep
819+
- `user_assigned_managed_identity_key` (string) - Managed identity key ('plan' or 'apply')
820+
- `scope` (string) - Assignment scope ('management_group' or 'subscription')
821+
822+
Default includes 3 assignments:
823+
- Plan and apply access operations
824+
EOT
825+
type = map(object({
826+
built_in_role_definition_name = optional(string)
827+
custom_role_definition_key = optional(string)
828+
user_assigned_managed_identity_key = string
829+
scope = string
830+
}))
831+
default = {
832+
plan = {
833+
custom_role_definition_key = "Reader"
938834
user_assigned_managed_identity_key = "plan"
939-
scope = "subscription"
835+
scope = "management_group"
940836
}
941-
apply_subscription = {
942-
custom_role_definition_key = "alz_subscription_owner"
837+
plan_custom = {
838+
custom_role_definition_key = "alz_reader"
839+
user_assigned_managed_identity_key = "plan"
840+
scope = "management_group"
841+
}
842+
apply_management_group = {
843+
custom_role_definition_key = "Owner"
943844
user_assigned_managed_identity_key = "apply"
944-
scope = "subscription"
845+
scope = "management_group"
945846
}
946847
}
947848
}
948849

949-
variable "role_assignments_bicep" {
850+
variable "role_assignments_bicep_classic" {
950851
description = <<-EOT
951-
**(Optional)** RBAC role assignments for Bicep-based deployments.
852+
**(Optional)** RBAC role assignments for Bicep Classic based deployments.
952853
953854
Map of role assignment configurations where:
954855
- **Key**: Assignment identifier (e.g., 'plan_management_group')
955856
- **Value**: Object containing:
857+
- `built_in_role_definition_name` (string) - Name of built-in role (e.g., 'Owner', 'Contributor')
956858
- `custom_role_definition_key` (string) - Key from custom_role_definitions_bicep
957859
- `user_assigned_managed_identity_key` (string) - Managed identity key ('plan' or 'apply')
958860
- `scope` (string) - Assignment scope ('management_group' or 'subscription')
@@ -962,7 +864,8 @@ variable "role_assignments_bicep" {
962864
- Plan and apply access for subscription operations
963865
EOT
964866
type = map(object({
965-
custom_role_definition_key = string
867+
built_in_role_definition_name = optional(string)
868+
custom_role_definition_key = optional(string)
966869
user_assigned_managed_identity_key = string
967870
scope = string
968871
}))
@@ -1078,3 +981,14 @@ variable "bicep_tenant_role_assignment_role_definition_name" {
1078981
type = string
1079982
default = "Landing Zone Management Owner"
1080983
}
984+
985+
variable "terraform_architecture_file_path" {
986+
description = <<-EOT
987+
**(Required)** Relative path to the Terraform architecture definition JSON file within the module folder.
988+
989+
This file defines the structure and components of the Terraform deployment architecture.
990+
Used for dynamic file manipulation based on architecture specifics.
991+
EOT
992+
type = string
993+
default = "lib/architecture_definitions/alz_custom.alz_architecture_definition.yaml"
994+
}

alz/github/main.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,17 @@ module "azure" {
6060
container_registry_dockerfile_name = var.runner_container_image_dockerfile
6161
container_registry_dockerfile_repository_folder_url = local.runner_container_instance_dockerfile_url
6262
custom_role_definitions = var.iac_type == "terraform" ? local.custom_role_definitions_terraform : (var.iac_type == "bicep" ? local.custom_role_definitions_bicep : local.custom_role_definitions_bicep_classic)
63-
role_assignments = var.iac_type == "terraform" ? var.role_assignments_terraform : var.role_assignments_bicep
63+
role_assignments = var.iac_type == "terraform" ? var.role_assignments_terraform : (var.iac_type == "bicep" ? var.role_assignments_bicep : var.role_assignments_bicep_classic)
6464
storage_account_blob_soft_delete_enabled = var.storage_account_blob_soft_delete_enabled
6565
storage_account_blob_soft_delete_retention_days = var.storage_account_blob_soft_delete_retention_days
6666
storage_account_blob_versioning_enabled = var.storage_account_blob_versioning_enabled
6767
storage_account_container_soft_delete_enabled = var.storage_account_container_soft_delete_enabled
6868
storage_account_container_soft_delete_retention_days = var.storage_account_container_soft_delete_retention_days
6969
tenant_role_assignment_enabled = var.iac_type == "bicep" && var.bicep_tenant_role_assignment_enabled
7070
tenant_role_assignment_role_definition_name = var.bicep_tenant_role_assignment_role_definition_name
71+
intermediate_root_management_group_creation_enabled = var.iac_type != "bicep-classic"
72+
intermediate_root_management_group_id = module.file_manipulation.intermediate_root_management_group_id
73+
intermediate_root_management_group_display_name = module.file_manipulation.intermediate_root_management_group_display_name
7174
}
7275

7376
module "github" {
@@ -122,4 +125,5 @@ module "file_manipulation" {
122125
pipeline_files_directory_path = local.pipeline_files_directory_path
123126
pipeline_template_files_directory_path = local.pipeline_template_files_directory_path
124127
concurrency_value = local.resource_names.storage_container
128+
terraform_architecture_file_path = var.terraform_architecture_file_path
125129
}

0 commit comments

Comments
 (0)