-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
efs.tf
56 lines (48 loc) · 1.63 KB
/
efs.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
# https://docs.aws.amazon.com/eks/latest/userguide/efs-csi.html
module "iam_assumable_role_efs_csi" {
count = var.efs_enabled ? 1 : 0
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc"
version = "5.46.0"
create_role = true
role_name = "${var.environment_name}-AmazonEFSCSIDriverPolicy"
provider_url = replace(aws_iam_openid_connect_provider.cluster.url, "https://", "")
role_policy_arns = ["arn:aws:iam::aws:policy/service-role/AmazonEFSCSIDriverPolicy"]
# namespace and service account name
oidc_fully_qualified_subjects = [
"system:serviceaccount:kube-system:efs-csi-controller-sa",
"system:serviceaccount:kube-system:efs-csi-node-sa",
"system:serviceaccount:kube-system:efs-csi-*",
]
oidc_fully_qualified_audiences = [
"sts.amazonaws.com"
]
tags = {
"KubespotEnvironment" = var.environment_name
}
}
resource "kubernetes_service_account" "efs_csi_controller_sa" {
count = var.efs_enabled ? 1 : 0
metadata {
name = "efs-csi-controller-sa"
namespace = "kube-system"
labels = {
"app.kubernetes.io/name" = "aws-efs-csi-driver"
}
annotations = {
"eks.amazonaws.com/role-arn" = module.iam_assumable_role_efs_csi[0].iam_role_arn
}
}
}
resource "kubernetes_service_account" "efs_csi_node_sa" {
count = var.efs_enabled ? 1 : 0
metadata {
name = "efs-csi-node-sa"
namespace = "kube-system"
labels = {
"app.kubernetes.io/name" = "aws-efs-csi-driver"
}
annotations = {
"eks.amazonaws.com/role-arn" = module.iam_assumable_role_efs_csi[0].iam_role_arn
}
}
}