Skip to content

Commit

Permalink
Add conditional creation of RBAC resources for connect gateway users
Browse files Browse the repository at this point in the history
  • Loading branch information
SadriG91 committed Dec 10, 2024
1 parent 8448689 commit 43bedc2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion connect-gateway-rbac.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ locals {
}

resource "kubernetes_cluster_role" "gateway_impersonate" {
count = length(var.connect_gateway_users) > 0 ? 1 : 0

metadata {
name = "gateway-impersonate"
}
Expand All @@ -15,25 +17,31 @@ resource "kubernetes_cluster_role" "gateway_impersonate" {
resource_names = var.connect_gateway_users
verbs = ["impersonate"]
}
depends_on = [module.cluster_credentials]
}

resource "kubernetes_cluster_role_binding" "gateway_impersonate" {
count = length(var.connect_gateway_users) > 0 ? 1 : 0

metadata {
name = "gateway-impersonate"
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "ClusterRole"
name = kubernetes_cluster_role.gateway_impersonate.metadata[0].name
name = kubernetes_cluster_role.gateway_impersonate[0].metadata[0].name
}
subject {
kind = "ServiceAccount"
name = local.service_account.name
namespace = local.service_account.namespace
}
depends_on = [module.cluster_credentials]
}

resource "kubernetes_cluster_role_binding" "gateway_cluster_admin" {
count = length(var.connect_gateway_users) > 0 ? 1 : 0

metadata {
name = "gateway-cluster-admin"
}
Expand All @@ -50,4 +58,5 @@ resource "kubernetes_cluster_role_binding" "gateway_cluster_admin" {
name = subject.value
}
}
depends_on = [module.cluster_credentials]
}

0 comments on commit 43bedc2

Please sign in to comment.