From efecd2ed871bec6b6d9150d6ff0862ba63895769 Mon Sep 17 00:00:00 2001 From: Steve Davids Date: Fri, 29 Jun 2018 18:39:22 -0400 Subject: [PATCH] Allowing a more configurable kubeconfig --- data.tf | 19 ++++++++++++++++++- templates/kubeconfig.tpl | 16 +++++++++------- variables.tf | 25 +++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/data.tf b/data.tf index 9fe0727..76ebcad 100644 --- a/data.tf +++ b/data.tf @@ -44,7 +44,7 @@ data "aws_iam_policy_document" "cluster_assume_role_policy" { } } -data template_file kubeconfig { +data "template_file" "kubeconfig" { template = "${file("${path.module}/templates/kubeconfig.tpl")}" vars { @@ -52,6 +52,23 @@ data template_file kubeconfig { endpoint = "${aws_eks_cluster.this.endpoint}" region = "${data.aws_region.current.name}" cluster_auth_base64 = "${aws_eks_cluster.this.certificate_authority.0.data}" + context_name = "${var.kubeconfig_context_name}" + user_name = "${var.kubeconfig_user_name}" + aws_authenticator_command = "${var.kubeconfig_aws_authenticator_command}" + aws_authenticator_additional_args = "${length(var.kubeconfig_aws_authenticator_additional_args) > 0 ? " - ${join("\n - ", var.kubeconfig_aws_authenticator_additional_args)}" : "" }" + aws_authenticator_env_variables = "${length(var.kubeconfig_aws_authenticator_env_variables) > 0 ? " env:\n${join("\n", data.template_file.aws_authenticator_env_variables.*.rendered)}" : ""}" + } +} + +data "template_file" "aws_authenticator_env_variables" { + template = <