-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path040_eks_cluster.tf
More file actions
61 lines (54 loc) · 1.42 KB
/
040_eks_cluster.tf
File metadata and controls
61 lines (54 loc) · 1.42 KB
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
//EKS Master Cluster
//This resource is the actual Kubernetes master cluster. It can take a few minutes to provision in AWS.
resource "aws_eks_cluster" "eks-cluster" {
name = local.cluster_name
role_arn = aws_iam_role.EKSClusterRole.arn
version = var.cluster_version
vpc_config {
security_group_ids = [aws_security_group.eks-control-plane-sg.id]
subnet_ids = [
aws_subnet.eks-private.id,
aws_subnet.eks-private-2.id,
]
}
depends_on = [
aws_iam_role_policy_attachment.eks-policy-AmazonEKSClusterPolicy,
aws_iam_role_policy_attachment.eks-policy-AmazonEKSServicePolicy,
]
}
locals {
kubeconfig = <<KUBECONFIG
apiVersion: v1
clusters:
- cluster:
server: ${aws_eks_cluster.eks-cluster.endpoint}
certificate-authority-data: ${aws_eks_cluster.eks-cluster.certificate_authority[0].data}
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: aws
name: aws-${var.CLUSTER_NAME}
current-context: aws-${var.CLUSTER_NAME}
kind: Config
preferences: {}
users:
- name: aws
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
command: aws-iam-authenticator
args:
- "token"
- "-i"
- "${local.cluster_name}"
KUBECONFIG
}
output "kubeconfig" {
value = local.kubeconfig
}
resource "local_file" "kubeconfig" {
content = local.kubeconfig
filename = "${path.root}/kubeconfig"
file_permission = "0644"
}