Skip to content

Commit

Permalink
Issue #3: Remove adgroup creation since we have insufficient privileg…
Browse files Browse the repository at this point in the history
…es with current service principal
  • Loading branch information
SonOfLope committed Feb 14, 2024
1 parent a31341b commit cf7a1ef
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
36 changes: 18 additions & 18 deletions terraform/modules/azure-kubernetes-cluster/accounts.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ resource "azurerm_role_assignment" "admin" {
principal_id = each.value
}

resource "azurerm_role_assignment" "namespace-groups" {
for_each = toset(var.ad_groups)
scope = azurerm_kubernetes_cluster.k8s.id
role_definition_name = "Azure Kubernetes Service Cluster User Role"
principal_id = azuread_group.groups[each.value].id
}
# resource "azurerm_role_assignment" "namespace-groups" {
# for_each = toset(var.ad_groups)
# scope = azurerm_kubernetes_cluster.k8s.id
# role_definition_name = "Azure Kubernetes Service Cluster User Role"
# principal_id = azuread_group.groups[each.value].id
# }

data "azuread_client_config" "current" {}
# data "azuread_client_config" "current" {}

data "azuread_user" "users" {
for_each = toset(var.ad_members)
user_principal_name = each.value
}
# data "azuread_user" "users" {
# for_each = toset(var.ad_members)
# user_principal_name = each.value
# }

resource "azuread_group" "groups" {
display_name = each.value
for_each = toset(var.ad_groups)
owners = [data.azuread_client_config.current.object_id]
security_enabled = true
members = [for user in var.ad_members : data.azuread_user.users[user].object_id]
}
# resource "azuread_group" "groups" {
# display_name = each.value
# for_each = toset(var.ad_groups)
# owners = [data.azuread_client_config.current.object_id]
# security_enabled = true
# members = [for user in var.ad_members : data.azuread_user.users[user].object_id]
# }
18 changes: 9 additions & 9 deletions terraform/modules/azure-kubernetes-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ variable "aks_admin_group_object_ids" {
type = list(string)
}

variable "ad_groups" {
description = "ad groups to be used in aks rolebindings"
type = list(string)
}

variable "ad_members" {
description = "ad members to be added to ad_groups"
type = list(string)
}
# variable "ad_groups" {
# description = "ad groups to be used in aks rolebindings"
# type = list(string)
# }

# variable "ad_members" {
# description = "ad members to be added to ad_groups"
# type = list(string)
# }
16 changes: 8 additions & 8 deletions terraform/staging/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ variable "aks_admin_group_object_ids" {
type = list(string)
}

variable "ad_groups" {
description = "ad groups to be used in aks rolebindings"
type = list(string)
}
# variable "ad_groups" {
# description = "ad groups to be used in aks rolebindings"
# type = list(string)
# }

variable "ad_members" {
description = "ad members to be added to ad groups"
type = list(string)
}
# variable "ad_members" {
# description = "ad members to be added to ad groups"
# type = list(string)
# }

0 comments on commit cf7a1ef

Please sign in to comment.