Skip to content

Instantly share code, notes, and snippets.

@johann8384
Last active November 9, 2020 20:19
Show Gist options
  • Save johann8384/11effc7d78415fc363c5ea8f5e110557 to your computer and use it in GitHub Desktop.
Save johann8384/11effc7d78415fc363c5ea8f5e110557 to your computer and use it in GitHub Desktop.
#!/bin/bash
AWS="/usr/local/bin/aws"
JQ="/usr/local/bin/jq -r"
REGIONS=( "us-east-1" "us-east-2" "us-west-1" "us-west-2" "ap-northeast-1" "eu-west-1")
SSO_ROLE_NAME=$1
KUBE_CONFIG=$2
PROFILES=( "$3" )
function cluster-info {
local PROFILE=$1
local REGION=$2
local KUBE_CONFIG=$3
local CLUSTER_LIST=`${AWS} --profile=${PROFILE} eks list-clusters --region=${REGION}`
local CLUSTER_NAME=""
echo ${CLUSTER_LIST} | ${JQ} -r -c '.clusters[]' | while read CLUSTER_NAME;
do
${AWS} --profile=${PROFILE} eks --region ${REGION} update-kubeconfig --name ${CLUSTER_NAME} --kubeconfig ${KUBE_CONFIG} --alias ${CLUSTER_NAME}
done
}
for PROFILE in ${PROFILES[@]};
do
for REGION in ${REGIONS[@]};
do
cluster-info ${PROFILE} ${REGION} ${KUBE_CONFIG}
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment