@@ -101,7 +101,7 @@ data "azurerm_client_config" "current" {}
101101# principal_id = azuread_service_principal.github_actions.object_id
102102# }
103103
104- # Facing issues with the custom role definition, so using the built-in Contributor role instead. Figure it out later
104+ # Facing issues with the custom role definition, so using the built-in Contributor role instead. Because I cannot create custom role definitions.
105105# For resource group creation/management (required by networking fixture)
106106# Note: No specific "Resource Group Contributor" role exists - using generic Contributor
107107# resource "azurerm_role_assignment" "github_actions_contributor" {
@@ -130,7 +130,7 @@ data "azurerm_client_config" "current" {}
130130# ]
131131# }
132132
133- # # Assign the custom resource group role
133+ # # Assign the custom resource group role not able to perform this getting authz error
134134# resource "azurerm_role_assignment" "github_actions_resource_group_manager" {
135135# scope = "/subscriptions/${data.azurerm_client_config.current.subscription_id}"
136136# role_definition_id = azurerm_role_definition.resource_group_manager.role_definition_resource_id
@@ -142,3 +142,40 @@ resource "azurerm_role_assignment" "github_actions_contributor" {
142142 role_definition_name = " Contributor"
143143 principal_id = azuread_service_principal. github_actions . object_id
144144}
145+
146+ # RBAC Administrator role for AKS role assignments
147+ # AKS modules need to assign network roles to managed identities and subnets
148+ # Commented out due to ABAC restrictions - use more specific roles instead
149+ # Maybe make it more restrictive to only assing
150+ # ---> Network Contributor and Storage Blob Data Contributor since we only assign those in az modules
151+ resource "azurerm_role_assignment" "github_actions_rbac_admin" {
152+ scope = " /subscriptions/${ data . azurerm_client_config . current . subscription_id } "
153+ role_definition_name = " Role Based Access Control Administrator"
154+ principal_id = azuread_service_principal. github_actions . object_id
155+
156+ # ABAC condition to block assignment of high-privilege roles
157+ # Allows assignment of any role EXCEPT: Owner, User Access Administrator, RBAC Administrator
158+ # Role GUIDs: 8e3af657... (Owner), 18d7d88d... (User Access Admin), f58310d9... (RBAC Admin)
159+ condition = <<- EOT
160+ (
161+ (!(ActionMatches{'Microsoft.Authorization/roleAssignments/write'}))
162+ OR
163+ (@Request[Microsoft.Authorization/roleAssignments:RoleDefinitionId] ForAnyOfAllValues:GuidNotEquals {
164+ 8e3af657-a8ff-443c-a75c-2fe8c4bcb635,
165+ 18d7d88d-d35e-4fb5-a5c3-7773c20a72d9,
166+ f58310d9-a9f6-439a-9e8d-f62e7b41a168
167+ })
168+ )
169+ AND
170+ (
171+ (!(ActionMatches{'Microsoft.Authorization/roleAssignments/delete'}))
172+ OR
173+ (@Resource[Microsoft.Authorization/roleAssignments:RoleDefinitionId] ForAnyOfAllValues:GuidNotEquals {
174+ 8e3af657-a8ff-443c-a75c-2fe8c4bcb635,
175+ 18d7d88d-d35e-4fb5-a5c3-7773c20a72d9,
176+ f58310d9-a9f6-439a-9e8d-f62e7b41a168
177+ })
178+ )
179+ EOT
180+ condition_version = " 2.0"
181+ }
0 commit comments