#!/usr/bin/env bash
set -euo pipefail

unset KUBECONFIG

awsRegions=( us-west-2 us-east-1 ap-southeast-1 )

function awsKubeConfig(){
    aws eks --region $1 --output text list-clusters | awk '{print $2}' | xargs -n 1 -I {} aws eks --region $1 update-kubeconfig --name {}
}

# update kubeconfig for AWS EKS cluster
for region in "${awsRegions[@]}"
do
  awsKubeConfig $region
done

kubectl config get-contexts
