-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheks.tf
57 lines (44 loc) · 1.24 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
resource "aws_iam_role" "eks_cluster" {
name = "eks_cluster"
# Terraform's "jsonencode" function converts a
# Terraform expression result to valid JSON syntax.
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "eks.amazonaws.com"
}
},
]
})
}
resource "aws_iam_role_policy_attachment" "amazon_eks_cluster_policy" {
#policy that we want to apply to the role
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
#role where policy should be applied
role = aws_iam_role.eks_cluster.name
}
resource "aws_eks_cluster" "eks" {
name = "eks"
role_arn = aws_iam_role.eks_cluster.arn
version = "1.28"
vpc_config {
# should be true if we have bastion for access
endpoint_private_access = false
# if we don't have bastion and we are accessing cluster from our laptop this should be true
endpoint_public_access = true
subnet_ids = [
aws_subnet.public_1.id,
aws_subnet.public_2.id,
aws_subnet.private_1.id,
aws_subnet.private_2.id
]
}
depends_on = [
aws_iam_role_policy_attachment.amazon_eks_cluster_policy
]
}