Skip to content

Commit

Permalink
update aks module to use useridentity
Browse files Browse the repository at this point in the history
  • Loading branch information
SazniMohamed committed Dec 12, 2023
1 parent f09753e commit 5fa9633
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/azurerm/AKS-Firewall/role_assignment.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
resource "azurerm_role_assignment" "network_contributor_role_assignment_subnet" {
scope = azurerm_subnet.aks_node_pool_subnet.id
role_definition_name = "Network Contributor"
principal_id = azurerm_kubernetes_cluster.aks_cluster.identity[0].principal_id
principal_id = var.identity_type == "SystemAssigned" ? azurerm_kubernetes_cluster.aks_cluster.identity[0].principal_id : var.user_assigned_identity_principal_id
depends_on = [azurerm_kubernetes_cluster.aks_cluster, azurerm_subnet.aks_node_pool_subnet]
}

resource "azurerm_role_assignment" "aks_network_contributor_role_assignment_loadbalancer_subnet" {
scope = azurerm_subnet.internal_load_balancer_subnet.id
role_definition_name = "Network Contributor"
principal_id = azurerm_kubernetes_cluster.aks_cluster.identity[0].principal_id
principal_id = var.identity_type == "SystemAssigned" ? azurerm_kubernetes_cluster.aks_cluster.identity[0].principal_id : var.user_assigned_identity_principal_id
depends_on = [azurerm_kubernetes_cluster.aks_cluster, azurerm_subnet.internal_load_balancer_subnet]
}
6 changes: 6 additions & 0 deletions modules/azurerm/AKS-Firewall/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,9 @@ variable "user_assigned_identity_id" {
type = string
default = ""
}

variable "user_assigned_identity_principal_id" {
description = "User assigned identity principal id"
type = string
default = ""
}

0 comments on commit 5fa9633

Please sign in to comment.