Skip to content

Commit c81362c

Browse files
committed
remove redundant extra role assignments
1 parent 5d04ed6 commit c81362c

5 files changed

Lines changed: 2 additions & 53 deletions

File tree

alz/local/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ module "azure" {
3434
use_private_networking = false
3535
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)
3636
role_assignments = var.iac_type == "terraform" ? var.role_assignments_terraform : (var.iac_type == "bicep" ? var.role_assignments_bicep : var.role_assignments_bicep_classic)
37-
additional_role_assignment_principal_ids = var.grant_permissions_to_current_user ? { current_user = data.azurerm_client_config.current.object_id } : {}
3837
storage_account_blob_soft_delete_enabled = var.storage_account_blob_soft_delete_enabled
3938
storage_account_blob_soft_delete_retention_days = var.storage_account_blob_soft_delete_retention_days
4039
storage_account_blob_versioning_enabled = var.storage_account_blob_versioning_enabled

alz/local/variables.tf

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,6 @@ variable "postfix_number" {
188188
default = 1
189189
}
190190

191-
variable "grant_permissions_to_current_user" {
192-
description = <<-EOT
193-
**(Optional, default: `true`)** Whether to grant permissions to the current Azure CLI user.
194-
195-
When true, assigns permissions to the currently authenticated user in addition to the managed identities.
196-
Useful for local development and testing.
197-
EOT
198-
type = bool
199-
default = true
200-
}
201-
202191
variable "additional_files" {
203192
description = <<-EOT
204193
**(Optional, default: `[]`)** Additional files to include in the deployment.

modules/azure/role_assignments.tf

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,8 @@ locals {
77
principal_id = azurerm_user_assigned_identity.alz[value.user_assigned_managed_identity_key].principal_id
88
} }
99

10-
additional_role_assignments = { for assignment in flatten([
11-
for key, value in var.role_assignments : [
12-
for princial_key, principal_value in var.additional_role_assignment_principal_ids : {
13-
composite_key = "${value.scope}-${coalesce(value.custom_role_definition_key, value.built_in_role_definition_name)}-${princial_key}"
14-
user_assigned_managed_identity_key = "${value.scope}-${coalesce(value.custom_role_definition_key, value.built_in_role_definition_name)}-${princial_key}"
15-
built_in_role_definition_name = value.built_in_role_definition_name
16-
custom_role_definition_key = value.custom_role_definition_key
17-
scope = value.scope
18-
principal_id = principal_value
19-
}
20-
]]) : assignment.composite_key => {
21-
user_assigned_managed_identity_key = assignment.user_assigned_managed_identity_key
22-
built_in_role_definition_name = assignment.built_in_role_definition_name
23-
custom_role_definition_key = assignment.custom_role_definition_key
24-
scope = assignment.scope
25-
principal_id = assignment.principal_id
26-
} }
27-
28-
combined_role_assignments = merge(local.role_assignments, local.additional_role_assignments)
29-
3010
subscription_role_assignments = { for assignment in flatten([
31-
for key, value in local.combined_role_assignments : [
11+
for key, value in local.role_assignments : [
3212
for subscription_id, subscription in data.azurerm_subscription.alz : {
3313
key = "${value.user_assigned_managed_identity_key}-${coalesce(value.custom_role_definition_key, value.built_in_role_definition_name)}-${subscription_id}"
3414
scope = subscription.id
@@ -45,7 +25,7 @@ locals {
4525
} }
4626

4727
management_group_role_assignments = {
48-
for key, value in local.combined_role_assignments : key => {
28+
for key, value in local.role_assignments : key => {
4929
scope = var.intermediate_root_management_group_creation_enabled ? azapi_resource.intermediate_root_management_group[0].id : data.azurerm_management_group.alz.id
5030
role_definition_id = value.built_in_role_definition_name == null ? azurerm_role_definition.alz[value.custom_role_definition_key].role_definition_resource_id : null
5131
role_definition_name = value.built_in_role_definition_name

modules/azure/storage.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,3 @@ resource "azurerm_role_assignment" "alz_storage_container" {
6464
role_definition_name = "Storage Blob Data Owner"
6565
principal_id = azurerm_user_assigned_identity.alz[each.key].principal_id
6666
}
67-
68-
resource "azurerm_role_assignment" "alz_storage_container_additional" {
69-
for_each = var.create_storage_account ? var.additional_role_assignment_principal_ids : {}
70-
scope = azapi_resource.storage_account_container[0].id
71-
role_definition_name = "Storage Blob Data Owner"
72-
principal_id = each.value
73-
}

modules/azure/variables.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -610,18 +610,6 @@ variable "role_assignments" {
610610
}))
611611
}
612612

613-
variable "additional_role_assignment_principal_ids" {
614-
description = <<-EOT
615-
**(Optional, default: `{}`)** Additional Azure AD principal IDs to grant the same role assignments.
616-
617-
Map of principal IDs (users, groups, service principals) to grant the same role assignments
618-
as the managed identities. Useful for granting permissions to human operators or existing
619-
service principals for troubleshooting or manual operations.
620-
EOT
621-
type = map(string)
622-
default = {}
623-
}
624-
625613
variable "tenant_role_assignment_enabled" {
626614
description = <<-EOT
627615
**(Optional, default: `false`)** Enable tenant-level role assignment for managed identities.

0 commit comments

Comments
 (0)