Do you have an existing k8s config? Running

aws eks update-kubeconfig --region <region> --name <cluster name>

Generates a ~/.kube/config.

If you already have a ~/.kube/config, there could be a conflict between the file to be generated, and the file that already exists that prevents them from being merged.

If you have a ~/.kube/config file, and you aren't actively using it, running

rm ~/.kube/config

and then attempting

aws eks update-kubeconfig --region us-east-2 --name <cluster name>

afterwards will likely solve your issue.

If you are using your ~/.kube/config file, rename it something else so you could use it later, and then run the eks command again.

See a similar issue here: https://github.com/aws/aws-cli/issues/4843

Answer from emh221 on Stack Overflow
🌐
Amazon Web Services
docs.aws.amazon.com › cli › latest › reference › eks › update-kubeconfig.html
update-kubeconfig — AWS CLI 2.34.36 Command Reference
The following update-kubeconfig example configures your kubectl by creating or updating the kubeconfig (with role-arn option to assume a role for cluster authentication) so that you can connect to an Amazon EKS Cluster named my-eks-cluster. aws eks update-kubeconfig \ --name my-eks-cluster \ --role-arn arn:aws:iam::111122223333:role/eksctl-EKS-Linux-Cluster-v1-24-cluster-ServiceRole-j1k7AfTIQtnM
Discussions

role parameter in eks update-kubeconfig is not being used for aws cli connection
Describe the bug It seems that the role parameter in aws eks update-kubeconfig --role arn:aws:iam::1234567890:role/ASSUMEDROLE is only being inserted in to kube config and used for kubectl connecti... More on github.com
🌐 github.com
7
February 28, 2024
CLI version 1.22.0 breaks aws eks update-kubeconfig
aws eks update-kubeconfig --name ***** \ --region us-east-1 \ --role-arn ************ cat ~/.kube/config shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0} env: region: us-east-1 accountId: *** repo: *** namespace: *** environment-overlay: *** cluster-name: *** cluster-authenticati... More on github.com
🌐 github.com
6
November 8, 2021
EKS kubeconfig profile setting doesn't work when using environment varialbles for authentication
If the command is manually changed in the kubeconfig file to include the profile with the --profile argument then authentication works successfully. Perhaps this conditional could be changed to extend the executable arguments just like are done for the role_arn in line 330? aws --profile XXXX eks update... More on github.com
🌐 github.com
8
March 30, 2023
Appending new content to KubeConfig file
is there a way appending content to the file without changing it Perhaps I'm misunderstanding, but no, you can't append content to a file without changing it. Appending content is a change. aws eks update-kubeconfig appends by default; it does not recreate the kubeconfig. More on reddit.com
🌐 r/Terraform
8
1
July 14, 2022
🌐
ControlPlane
controlplane.com › blog › post › kubeconfig-file-for-the-aws-eks-cluster
How to create/update Kubeconfig file for the AWS EKS Cluster — Control Plane
November 2, 2023 - This command retrieves the necessary credentials and cluster configuration and updates your Kubeconfig file with the new cluster context. Verify whether your Kubeconfig is correctly configured using the below command: ... This command should ...
🌐
AWS
docs.aws.amazon.com › amazon eks › user guide › set up to use amazon eks
Set up to use Amazon EKS - Amazon EKS
In particular, you need AWS CLI to configure credentials, but you also need it with other AWS services. Set up kubectl and eksctl – The eksctl CLI interacts with AWS to create, modify, and delete Amazon EKS clusters.
Find elsewhere
🌐
Kubernetes
kubernetes.io › docs › tasks › tools › install-kubectl-windows
Install and Set Up kubectl on Windows | Kubernetes
May 15, 2025 - In order for kubectl to find and access a Kubernetes cluster, it needs a kubeconfig file, which is created automatically when you create a cluster using kube-up.sh or successfully deploy a Minikube cluster.
🌐
Atmos
atmos.tools › commands › aws › eks › update-kubeconfig
atmos aws eks update-kubeconfig | atmos
This command downloads kubeconfig from an EKS cluster and saves it to a file. It supports multiple execution modes: CLI parameters only: If all the required parameters (cluster name and AWS profile/role) are provided on the command-line, then Atmos executes the command without requiring the ...
🌐
GitHub
github.com › aws › aws-cli › issues › 8554
role parameter in eks update-kubeconfig is not being used for aws cli connection · Issue #8554 · aws/aws-cli
February 28, 2024 - Currently, I have to create a new AWS profile and specify the role_arn to ASSUMEDROLE and source as account A profile and run aws eks update-kubeconfig --name clusterB --role arn:aws:iam::ACCOUNTB#:role/ASSUMEDROLE --profile=NEWPROFILE to get the config.
Author   xcompass
🌐
Medium
amod-kadam.medium.com › how-does-kubeconfig-works-with-aws-eks-get-token-8a19ff4c5814
How does kubeconfig works with aws eks get-token ? | by Aamod Kadam | Medium
March 18, 2025 - In this post we will create kubeconfig manually and understand how it works with aws eks get-token.
🌐
GitHub
github.com › aws › aws-cli › issues › 6537
CLI version 1.22.0 breaks aws eks update-kubeconfig · Issue #6537 · aws/aws-cli
November 8, 2021 - aws eks update-kubeconfig --name ***** \ --region us-east-1 \ --role-arn ************ cat ~/.kube/config shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0} env: region: us-east-1 accountId: *** repo: *** namespace: *** environment-overlay: *** cluster-name: *** cluster-authenticati...
Author   toly-k
🌐
Kubernetes
kubernetes.io › docs › tasks › configure-pod-container › configure-service-account
Configure Service Accounts for Pods | Kubernetes
October 31, 2024 - Last modified October 31, 2024 at 4:23 PM PST: Update ServiceAccountTokenJTI, ServiceAccountTokenPodNodeInfo, ServiceAccountTokenNodeBindingValidation to stable (2aca56ea10)
🌐
FreeKB
freekb.net › Article
Create or Update kube config using the AWS CLI
~]$ aws eks update-kubeconfig --name my-cluster Added new context arn:aws:eks:us-east-1:123456789012:cluster/my-cluster to /home/john.doe/.kube/config
🌐
GitHub
github.com › aws › aws-cli › issues › 7794
EKS kubeconfig profile setting doesn't work when using environment varialbles for authentication · Issue #7794 · aws/aws-cli
March 30, 2023 - Generate a kubeconfig with aws --profile account2 eks update-kubeconfig --region {region} --name {eks-cluster-name}. Try to use that kubeconfig to interact with the cluster.
Author   tsaxon13
🌐
Teleport
goteleport.com › learn › dev-ops › kubectl-eks-management-guide
Managing Amazon EKS Clusters with kubectl: A Guide | Teleport
July 26, 2024 - After creating an EKS cluster (perhaps using terraform eks or the AWS Console), use the aws eks update-kubeconfig command to add your EKS cluster's configuration to your kubeconfig file:Replace <your-aws-region> with your AWS region (e.g., ...
🌐
Reddit
reddit.com › r/terraform › appending new content to kubeconfig file
r/Terraform on Reddit: Appending new content to KubeConfig file
July 14, 2022 -

Hey Guys ,

I've deployed a cluster on EKS ( AWS ) via terraform , and wondering if its possible to append new configuration content into the defaulted yaml configuration file without recreating it .

Currently I'm using provisioner for updating the file , but is there a way appending content to the file without changing it ?

resource "null_resource" "merge_kubeconfig" {   
triggers = {     
    always = timestamp()   
  }    
    depends_on = [module.eks_cluster]    

 provisioner "local-exec" {     
    interpreter = ["/bin/bash", "-c"]     
    command = <<EOT       
    set -e       
    echo 'Applying Auth ConfigMap with kubectl...'       
    aws eks wait cluster-active --name '${local.cluster_name}'       
    aws eks update-kubeconfig --name '${local.cluster_name}' --alias    '${local.cluster_name}-${var.region}' --region=${var.region} 
    EOT   } 
}

Thanks in advance !

🌐
GitHub
github.com › aws › aws-cli › issues › 5617
aws eks update-kubeconfig writes an insecure file · Issue #5617 · aws/aws-cli
October 8, 2020 - customizationIssues related to ... be added or improved. ... Describe the bug aws eks update-kubeconfig writes a world readable, group readable file, which the latest version of helm warns over:...
Author   Sarah-E-Greene
🌐
Typeshare
typeshare.co › jake › posts › easy-way-to-use-terraform-to-update-kubeconfig
Easy way to use Terraform to update kubeconfig for AWS | Typeshare
resource "null_resource" "kubectl" { provisioner "local-exec" { command = "aws eks --region ${var.region} update-kubeconfig --name ${local.cluster_name}" } }