forked from expel-io/terraform-aws-eks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
k8s_iam.tf
77 lines (72 loc) · 2.34 KB
/
k8s_iam.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# This Terraform file defines the necessary Kubernetes cluster role and cluster role binding resources for the "expel-reader" role.
# Resource: kubernetes_cluster_role.expel-reader-clusterrole
# This resource defines a Kubernetes cluster role named "expel-reader-clusterrole". It grants read-only access to various Kubernetes resources.
# The role allows the user specified in the variable "var.expel_k8s_user_name" to perform "get" and "list" operations on the specified resources.
resource "kubernetes_cluster_role" "expel-reader-clusterrole" {
metadata {
name = var.expel_k8s_cluster_role_name
}
rule {
api_groups = [
"",
"admissionregistration.k8s.io",
"apps",
"networking.k8s.io",
"rbac.authorization.k8s.io"
]
resources = [
"apiservices",
"clusterrolebindings",
"clusterroles",
"cronjobs",
"daemonsets",
"deployments",
"events",
"flowschemas",
"horizontalpodautoscalers",
"ingressclasses",
"ingresses",
"jobs",
"localsubjectaccessreviews",
"mutatingwebhookconfigurations",
"namespaces",
"networkpolicies",
"nodes",
"persistentvolumes",
"poddisruptionbudgets",
"pods",
"podsecuritypolicies",
"podtemplates",
"replicasets",
"rolebindings",
"roles",
"selfsubjectaccessreviews",
"selfsubjectrulesreviews",
"serviceaccounts",
"services",
"statefulsets",
"subjectaccessreviews",
"tokenreviews",
"validatingwebhookconfigurations",
"volumeattachments"
]
verbs = ["get", "list"]
}
}
# Resource: kubernetes_cluster_role_binding.expel-reader-cluster-role-binding
# This resource defines a Kubernetes cluster role binding named "expel-reader-clusterrolebinding". It binds the "expel-reader-clusterrole" to the user specified in the variable "var.expel_k8s_user_name".
# The cluster role binding allows the user to assume the permissions defined in the "expel-reader-clusterrole".
resource "kubernetes_cluster_role_binding" "expel-reader-cluster-role-binding" {
metadata {
name = "expel-reader-clusterrolebinding"
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "ClusterRole"
name = var.expel_k8s_cluster_role_name
}
subject {
kind = "User"
name = var.expel_k8s_user_name
}
}