-
Notifications
You must be signed in to change notification settings - Fork 0
/
eks-roles.tf
76 lines (63 loc) · 2.14 KB
/
eks-roles.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
data "aws_iam_policy_document" "eks_cluster_trust_policy" {
statement {
effect = "Allow"
principals {
type = "Service"
identifiers = ["eks.amazonaws.com"]
}
actions = ["sts:AssumeRole"]
}
}
data "aws_iam_policy" "eks_cluster_policy_1" {
name = "AmazonEKSClusterPolicy"
}
data "aws_iam_policy" "eks_cluster_policy_2" {
name = "AmazonEKSVPCResourceController"
}
resource "aws_iam_role" "eks_cluster_role" {
name = "${local.project_name}-${var.eks_cluster_role_name}"
assume_role_policy = data.aws_iam_policy_document.eks_cluster_trust_policy.json
}
resource "aws_iam_role_policy_attachment" "eks_cluster_role_policy_1" {
role = aws_iam_role.eks_cluster_role.name
policy_arn = data.aws_iam_policy.eks_cluster_policy_1.arn
}
resource "aws_iam_role_policy_attachment" "eks_cluster_role_policy_2" {
role = aws_iam_role.eks_cluster_role.name
policy_arn = data.aws_iam_policy.eks_cluster_policy_2.arn
}
data "aws_iam_policy_document" "eks_node_trust_policy" {
statement {
effect = "Allow"
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
actions = ["sts:AssumeRole"]
}
}
data "aws_iam_policy" "eks_node_policy_1" {
name = "AmazonEKSWorkerNodePolicy"
}
data "aws_iam_policy" "eks_node_policy_2" {
name = "AmazonEC2ContainerRegistryReadOnly"
}
data "aws_iam_policy" "eks_node_policy_3" {
name = "AmazonEKS_CNI_Policy"
}
resource "aws_iam_role" "eks_node_role" {
name = "${local.project_name}-${var.eks_node_role_name}"
assume_role_policy = data.aws_iam_policy_document.eks_node_trust_policy.json
}
resource "aws_iam_role_policy_attachment" "eks_node_role_policy_1" {
role = aws_iam_role.eks_node_role.name
policy_arn = data.aws_iam_policy.eks_node_policy_1.arn
}
resource "aws_iam_role_policy_attachment" "eks_node_role_policy_2" {
role = aws_iam_role.eks_node_role.name
policy_arn = data.aws_iam_policy.eks_node_policy_2.arn
}
resource "aws_iam_role_policy_attachment" "eks_node_role_policy_3" {
role = aws_iam_role.eks_node_role.name
policy_arn = data.aws_iam_policy.eks_node_policy_3.arn
}