-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddons.tf
More file actions
63 lines (53 loc) · 1.77 KB
/
addons.tf
File metadata and controls
63 lines (53 loc) · 1.77 KB
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
# TODO:
# load balancer controller
# karpenter or cluster-autoscaler
resource "aws_eks_addon" "secrets" {
cluster_name = aws_eks_cluster.this.name
addon_name = "aws-secrets-store-csi-driver-provider"
addon_version = null
resolve_conflicts_on_update = "PRESERVE"
tags = local.tags
timeouts {
create = "30m"
}
}
resource "aws_iam_role" "efs_csi" {
name = "${local.resource_name}-efs-csi"
assume_role_policy = data.aws_iam_policy_document.efs_csi_assume.json
tags = local.tags
}
data "aws_iam_policy_document" "efs_csi_assume" {
statement {
effect = "Allow"
actions = ["sts:AssumeRoleWithWebIdentity"]
principals {
type = "Federated"
identifiers = [aws_iam_openid_connect_provider.this.arn]
}
condition {
test = "StringEquals"
variable = "${replace(aws_iam_openid_connect_provider.this.url, "https://", "")}:sub"
values = ["system:serviceaccount:kube-system:efs-csi-controller-sa"]
}
condition {
test = "StringEquals"
variable = "${replace(aws_iam_openid_connect_provider.this.url, "https://", "")}:aud"
values = ["sts.amazonaws.com"]
}
}
}
resource "aws_iam_role_policy_attachment" "efs_csi" {
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonEFSCSIDriverPolicy"
role = aws_iam_role.efs_csi.name
}
resource "aws_eks_addon" "efs" {
cluster_name = aws_eks_cluster.this.name
addon_name = "aws-efs-csi-driver"
addon_version = null
resolve_conflicts_on_update = "PRESERVE"
service_account_role_arn = aws_iam_role.efs_csi.arn
tags = local.tags
timeouts {
create = "30m"
}
}