Skip to content

Commit

Permalink
Issue #3: Adds member addition to ad created groups
Browse files Browse the repository at this point in the history
  • Loading branch information
SonOfLope committed Feb 13, 2024
1 parent fb45aba commit 7b14138
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions terraform/modules/azure-kubernetes-cluster/accounts.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,14 @@ resource "azuread_group" "groups" {
owners = [data.azuread_client_config.current.object_id]
security_enabled = true
}

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

resource "azuread_group_member" "add_members" {
for_each = toset(var.ad_groups)
group_object_id = azuread_group.groups[each.value].object_id
member_object_id = data.azuread_user.users[each.value].object_id
}
5 changes: 5 additions & 0 deletions terraform/modules/azure-kubernetes-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,8 @@ 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)
}
1 change: 1 addition & 0 deletions terraform/staging/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ module "aks-cluster-0" {
rbac_enabled = var.rbac_enabled
aks_admin_group_object_ids = var.aks_admin_group_object_ids
ad_groups = var.ad_groups
ad_members = var.ad_members

network_resource_group = module.cluster-network-0.resource_group_name
network_vnet = module.cluster-network-0.virtual_network_name
Expand Down
5 changes: 5 additions & 0 deletions terraform/staging/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,8 @@ 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)
}

0 comments on commit 7b14138

Please sign in to comment.