-
Notifications
You must be signed in to change notification settings - Fork 0
/
eks.tf
54 lines (46 loc) · 1.57 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
resource "aws_eks_cluster" "example" {
name = var.cluster_name
role_arn = aws_iam_role.cluster.arn
vpc_config {
subnet_ids = [aws_subnet.example_a.id, aws_subnet.example_b.id]
}
depends_on = [
aws_subnet.example_a,
aws_subnet.example_b,
aws_iam_role_policy_attachment.AmazonEKSClusterPolicy,
aws_iam_role_policy_attachment.AmazonEKSVPCResourceController,
aws_iam_role_policy_attachment.ClusterIAMFullAccess,
]
}
resource "aws_eks_node_group" "example" {
cluster_name = var.cluster_name
node_group_name = "${var.cluster_name}-nodes"
node_role_arn = aws_iam_role.workers.arn
subnet_ids = [aws_subnet.example_a.id, aws_subnet.example_b.id]
scaling_config {
desired_size = var.desired_size
max_size = var.max_size
min_size = var.min_size
}
instance_types = [var.instance_type]
depends_on = [
aws_subnet.example_a,
aws_subnet.example_b,
aws_eks_cluster.example,
aws_iam_role_policy_attachment.AmazonEKSClusterPolicy,
aws_iam_role_policy_attachment.AmazonEKSVPCResourceController,
aws_iam_role_policy_attachment.WorkersIAMFullAccess,
aws_iam_role_policy_attachment.AmazonEKS_CNI_Policy
]
}
resource "local_file" "kubeconfig" {
content = templatefile("kubeconfig.tpl", {
endpoint = aws_eks_cluster.example.endpoint
certificate_authority_data = aws_eks_cluster.example.certificate_authority.0.data
cluster_name = aws_eks_cluster.example.name
})
filename = "${path.module}/kubeconfig.yaml"
depends_on = [
aws_eks_cluster.example
]
}