-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam_worker.tf
38 lines (33 loc) · 1.11 KB
/
iam_worker.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
# IAM role for EKS Worker Nodes
resource "aws_iam_role" "eks_worker_role" {
name = var.worker_iam_role_name
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Action = "sts:AssumeRole",
Effect = "Allow",
Principal = {
Service = "ec2.amazonaws.com"
},
},
]
})
}
# Attach required policies to the IAM role
resource "aws_iam_role_policy_attachment" "registry_ro" {
role = aws_iam_role.eks_worker_role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
}
resource "aws_iam_role_policy_attachment" "eks_worker_policy" {
role = aws_iam_role.eks_worker_role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
}
resource "aws_iam_role_policy_attachment" "eks_cni_policy" {
role = aws_iam_role.eks_worker_role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
}
resource "aws_iam_role_policy_attachment" "eks_worker_instance_core" {
role = aws_iam_role.eks_worker_role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
}