mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-04-18 06:49:37 +02:00
allow user to overwrite the kubeconfig default args (#129)
* allow user to overwrite the kubeconfig default args * quote args to auth command
This commit is contained in:
committed by
Max Williams
parent
31ec0f7db3
commit
e1e265bf21
4
data.tf
4
data.tf
@@ -44,13 +44,13 @@ data "template_file" "kubeconfig" {
|
|||||||
template = "${file("${path.module}/templates/kubeconfig.tpl")}"
|
template = "${file("${path.module}/templates/kubeconfig.tpl")}"
|
||||||
|
|
||||||
vars {
|
vars {
|
||||||
cluster_name = "${aws_eks_cluster.this.name}"
|
|
||||||
kubeconfig_name = "${local.kubeconfig_name}"
|
kubeconfig_name = "${local.kubeconfig_name}"
|
||||||
endpoint = "${aws_eks_cluster.this.endpoint}"
|
endpoint = "${aws_eks_cluster.this.endpoint}"
|
||||||
region = "${data.aws_region.current.name}"
|
region = "${data.aws_region.current.name}"
|
||||||
cluster_auth_base64 = "${aws_eks_cluster.this.certificate_authority.0.data}"
|
cluster_auth_base64 = "${aws_eks_cluster.this.certificate_authority.0.data}"
|
||||||
aws_authenticator_command = "${var.kubeconfig_aws_authenticator_command}"
|
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_command_args = "${length(var.kubeconfig_aws_authenticator_command_args) > 0 ? " - ${join("\n - ", var.kubeconfig_aws_authenticator_command_args)}" : " - ${join("\n - ", formatlist("\"%s\"", list("token", "-i", aws_eks_cluster.this.name)))}"}"
|
||||||
|
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)}" : ""}"
|
aws_authenticator_env_variables = "${length(var.kubeconfig_aws_authenticator_env_variables) > 0 ? " env:\n${join("\n", data.template_file.aws_authenticator_env_variables.*.rendered)}" : ""}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ users:
|
|||||||
apiVersion: client.authentication.k8s.io/v1alpha1
|
apiVersion: client.authentication.k8s.io/v1alpha1
|
||||||
command: ${aws_authenticator_command}
|
command: ${aws_authenticator_command}
|
||||||
args:
|
args:
|
||||||
- "token"
|
${aws_authenticator_command_args}
|
||||||
- "-i"
|
|
||||||
- "${cluster_name}"
|
|
||||||
${aws_authenticator_additional_args}
|
${aws_authenticator_additional_args}
|
||||||
${aws_authenticator_env_variables}
|
${aws_authenticator_env_variables}
|
||||||
|
|||||||
@@ -102,6 +102,12 @@ variable "kubeconfig_aws_authenticator_command" {
|
|||||||
default = "aws-iam-authenticator"
|
default = "aws-iam-authenticator"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "kubeconfig_aws_authenticator_command_args" {
|
||||||
|
description = "Default arguments passed to the authenticator command. Defaults to [token -i $cluster_name]."
|
||||||
|
type = "list"
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
variable "kubeconfig_aws_authenticator_additional_args" {
|
variable "kubeconfig_aws_authenticator_additional_args" {
|
||||||
description = "Any additional arguments to pass to the authenticator such as the role to assume. e.g. [\"-r\", \"MyEksRole\"]."
|
description = "Any additional arguments to pass to the authenticator such as the role to assume. e.g. [\"-r\", \"MyEksRole\"]."
|
||||||
type = "list"
|
type = "list"
|
||||||
|
|||||||
Reference in New Issue
Block a user