-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathebs-csi-driver.tf
More file actions
65 lines (56 loc) · 1.79 KB
/
ebs-csi-driver.tf
File metadata and controls
65 lines (56 loc) · 1.79 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
64
65
data "aws_iam_policy_document" "ebs_csi_driver" {
statement {
effect = "Allow"
principals {
type = "Service"
identifiers = ["pods.eks.amazonaws.com"]
}
actions = [
"sts:AssumeRole",
"sts:TagSession"
]
}
}
resource "aws_iam_role" "ebs_csi_driver" {
name = "${aws_eks_cluster.eks.name}-ebs-csi-driver"
assume_role_policy = data.aws_iam_policy_document.ebs_csi_driver.json
}
resource "aws_iam_role_policy_attachment" "ebs_csi_driver" {
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy"
role = aws_iam_role.ebs_csi_driver.name
}
# Optional: only if you want to encrypt the EBS drives
resource "aws_iam_policy" "ebs_csi_driver_encryption" {
name = "${aws_eks_cluster.eks.name}-ebs-csi-driver-encryption"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"kms:Decrypt",
"kms:GenerateDataKeyWithoutPlaintext",
"kms:CreateGrant"
]
Resource = "*"
}
]
})
}
# Optional: only if you want to encrypt the EBS drives
resource "aws_iam_role_policy_attachment" "ebs_csi_driver_encryption" {
policy_arn = aws_iam_policy.ebs_csi_driver_encryption.arn
role = aws_iam_role.ebs_csi_driver.name
}
resource "aws_eks_pod_identity_association" "ebs_csi_driver" {
cluster_name = aws_eks_cluster.eks.name
namespace = "kube-system"
service_account = "ebs-csi-controller-sa"
role_arn = aws_iam_role.ebs_csi_driver.arn
}
resource "aws_eks_addon" "ebs_csi_driver" {
cluster_name = aws_eks_cluster.eks.name
addon_name = "aws-ebs-csi-driver"
addon_version = "v1.38.1-eksbuild.2"
service_account_role_arn = aws_iam_role.ebs_csi_driver.arn
}