diff --git a/locals.tf b/locals.tf index 09dd589214..eeac2e3264 100644 --- a/locals.tf +++ b/locals.tf @@ -1,3 +1,5 @@ +data "aws_region" "current" {} + locals { # EKS Cluster @@ -162,12 +164,21 @@ locals { "t2.xlarge" ] + default_kubeconfig_aws_auth_args = [ + "eks", + "get-token", + "--cluster-name", + var.cluster_name, + "--region", + data.aws_region.current.name + ] + kubeconfig = var.create_eks ? templatefile("${path.module}/templates/kubeconfig.tpl", { kubeconfig_name = coalesce(var.kubeconfig_name, "eks_${var.cluster_name}") endpoint = local.cluster_endpoint cluster_auth_base64 = local.cluster_auth_base64 - aws_authenticator_command = var.kubeconfig_aws_authenticator_command - aws_authenticator_command_args = coalescelist(var.kubeconfig_aws_authenticator_command_args, ["token", "-i", local.cluster_name]) + aws_authenticator_command = coalesce(var.kubeconfig_aws_authenticator_command, "aws") + aws_authenticator_command_args = coalescelist(var.kubeconfig_aws_authenticator_command_args, local.default_kubeconfig_aws_auth_args) aws_authenticator_additional_args = var.kubeconfig_aws_authenticator_additional_args aws_authenticator_env_variables = var.kubeconfig_aws_authenticator_env_variables }) : "" diff --git a/variables.tf b/variables.tf index a830e20a62..5d8bf33b6a 100644 --- a/variables.tf +++ b/variables.tf @@ -193,13 +193,13 @@ variable "workers_additional_policies" { } variable "kubeconfig_aws_authenticator_command" { - description = "Command to use to fetch AWS EKS credentials." + description = "Command to use to fetch AWS EKS credentials. Defaults to aws CLI (will use eks command)." type = string - default = "aws-iam-authenticator" + default = null } variable "kubeconfig_aws_authenticator_command_args" { - description = "Default arguments passed to the authenticator command. Defaults to [token -i $cluster_name]." + description = "Default arguments passed to the authenticator command. Defaults to [eks get-token ...]." type = list(string) default = [] } @@ -219,7 +219,7 @@ variable "kubeconfig_aws_authenticator_env_variables" { variable "kubeconfig_name" { description = "Override the default name used for items kubeconfig." type = string - default = "" + default = null } variable "cluster_create_timeout" {