-
Notifications
You must be signed in to change notification settings - Fork 0
/
eks.tf
148 lines (136 loc) · 5.72 KB
/
eks.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
locals {
eks_name = {
value = "${local.resource_prefix.value}-eks"
}
}
data aws_iam_policy_document "iam_policy_eks" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["eks.amazonaws.com"]
}
}
}
resource aws_iam_role "iam_for_eks" {
name = "${local.resource_prefix.value}-iam-for-eks"
assume_role_policy = data.aws_iam_policy_document.iam_policy_eks.json
tags = {
git_commit = "d68d2897add9bc2203a5ed0632a5cdd8ff8cefb0"
git_file = "terraform/aws/eks.tf"
git_last_modified_at = "2020-06-16 14:46:24"
git_last_modified_by = "[email protected]"
git_modifiers = "nimrodkor"
git_org = "bridgecrewio"
git_repo = "terragoat"
yor_trace = "de052596-21a0-43de-8153-469add277b18"
}
}
resource aws_iam_role_policy_attachment "policy_attachment-AmazonEKSClusterPolicy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
role = aws_iam_role.iam_for_eks.name
}
resource aws_iam_role_policy_attachment "policy_attachment-AmazonEKSServicePolicy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSServicePolicy"
role = aws_iam_role.iam_for_eks.name
}
resource aws_vpc "eks_vpc" {
cidr_block = "10.10.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
tags = merge({
Name = "${local.resource_prefix.value}-eks-vpc"
}, {
git_commit = "d68d2897add9bc2203a5ed0632a5cdd8ff8cefb0"
git_file = "terraform/aws/eks.tf"
git_last_modified_at = "2020-06-16 14:46:24"
git_last_modified_by = "[email protected]"
git_modifiers = "nimrodkor"
git_org = "bridgecrewio"
git_repo = "terragoat"
yor_trace = "1600ca6c-72f6-45c0-a71d-88e117e51d6b"
})
}
resource aws_subnet "eks_subnet1" {
vpc_id = aws_vpc.eks_vpc.id
cidr_block = "10.10.10.0/24"
availability_zone = "${var.region}a"
map_public_ip_on_launch = true
tags = merge({
Name = "${local.resource_prefix.value}-eks-subnet"
"kubernetes.io/cluster/${local.eks_name.value}" = "shared"
}, {
git_commit = "6e62522d2ab8f63740e53752b84a6e99cd65696a"
git_file = "terraform/aws/eks.tf"
git_last_modified_at = "2021-05-02 11:16:31"
git_last_modified_by = "[email protected]"
git_modifiers = "nimrodkor"
git_org = "bridgecrewio"
git_repo = "terragoat"
"kubernetes.io/cluster/$${local.eks_name.value}" = "shared"
yor_trace = "1fb4fa23-a5d6-4d6a-b7dc-88749383f48d"
}, {
"kubernetes.io/cluster/$$${local.eks_name.value}" = "shared"
"kubernetes.io/cluster/$${local.eks_name.value}" = "shared"
}, {
"kubernetes.io/cluster/$$$${local.eks_name.value}" = "shared"
"kubernetes.io/cluster/$$${local.eks_name.value}" = "shared"
"kubernetes.io/cluster/$${local.eks_name.value}" = "shared"
})
}
resource aws_subnet "eks_subnet2" {
vpc_id = aws_vpc.eks_vpc.id
cidr_block = "10.10.11.0/24"
availability_zone = "${var.region}b"
map_public_ip_on_launch = true
tags = merge({
Name = "${local.resource_prefix.value}-eks-subnet2"
"kubernetes.io/cluster/${local.eks_name.value}" = "shared"
}, {
git_commit = "6e62522d2ab8f63740e53752b84a6e99cd65696a"
git_file = "terraform/aws/eks.tf"
git_last_modified_at = "2021-05-02 11:16:31"
git_last_modified_by = "[email protected]"
git_modifiers = "nimrodkor"
git_org = "bridgecrewio"
git_repo = "terragoat"
"kubernetes.io/cluster/$${local.eks_name.value}" = "shared"
yor_trace = "9ce04af2-5321-4e6c-a262-e4d7c1f69525"
}, {
"kubernetes.io/cluster/$$${local.eks_name.value}" = "shared"
"kubernetes.io/cluster/$${local.eks_name.value}" = "shared"
}, {
"kubernetes.io/cluster/$$$${local.eks_name.value}" = "shared"
"kubernetes.io/cluster/$$${local.eks_name.value}" = "shared"
"kubernetes.io/cluster/$${local.eks_name.value}" = "shared"
})
}
resource aws_eks_cluster "eks_cluster" {
name = local.eks_name.value
role_arn = "${aws_iam_role.iam_for_eks.arn}"
vpc_config {
endpoint_private_access = true
subnet_ids = ["${aws_subnet.eks_subnet1.id}", "${aws_subnet.eks_subnet2.id}"]
}
depends_on = [
"aws_iam_role_policy_attachment.policy_attachment-AmazonEKSClusterPolicy",
"aws_iam_role_policy_attachment.policy_attachment-AmazonEKSServicePolicy",
]
tags = {
git_commit = "d68d2897add9bc2203a5ed0632a5cdd8ff8cefb0"
git_file = "terraform/aws/eks.tf"
git_last_modified_at = "2020-06-16 14:46:24"
git_last_modified_by = "[email protected]"
git_modifiers = "nimrodkor"
git_org = "bridgecrewio"
git_repo = "terragoat"
yor_trace = "7fa14261-c18d-4fa2-aec4-746f6e64d2d3"
}
}
output "endpoint" {
value = "${aws_eks_cluster.eks_cluster.endpoint}"
}
output "kubeconfig-certificate-authority-data" {
value = "${aws_eks_cluster.eks_cluster.certificate_authority.0.data}"
}