forked from neticdk/tf-aws-eks-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkubeconfig.tf
32 lines (26 loc) · 908 Bytes
/
kubeconfig.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
/*
* Copyright (c) 2019 Netic A/S. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
data "aws_caller_identity" "current" {}
data "template_file" "kubeconfig" {
template = file("${path.module}/templates/kubeconfig.tpl")
vars = {
server = join("", aws_eks_cluster.this.*.endpoint)
certificate_authority_data = aws_eks_cluster.this.certificate_authority[0].data
cluster_name = var.name
aws_role = format(
"arn:aws:iam::%s:role/%s",
data.aws_caller_identity.current.account_id,
var.aws_role_name,
)
aws_profile = var.aws_profile_name
}
}
resource "local_file" "kubeconfig" {
content = join("", data.template_file.kubeconfig.*.rendered)
filename = local.kubeconfig_filename
depends_on = [aws_eks_cluster.this]
}