-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure_connection.sh
executable file
·34 lines (27 loc) · 957 Bytes
/
configure_connection.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
# Exit when any command fails
set -e
# Bold and normal font modifiers
bold=$(tput bold)
normal=$(tput sgr0)
# Trap always the last command executed
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
#trap all errors
trap 'catch $?' EXIT
catch() {
if [[ "$1" != "0" ]]; then
echo "${bold}\"${previous_command}\" command failed with exit code $1.${normal}"
fi
}
# Bold and normal font modifiers
bold=$(tput bold)
normal=$(tput sgr0)
#Configure aws cli
aws configure
read -r -p "Enter EKS cluster name [Obtained from the terraform output]: " CLUSTER_NAME
read -r -p "Enter the cluster_auth_role_arn [Obtained from the terraform output]: " ROLE_ARN
#Configure .kubeconfig for kubectl to point to the cluster.
aws eks update-kubeconfig --name ${CLUSTER_NAME} --role-arn ${ROLE_ARN}
#Verify that the authentication was successful
kubectl auth can-i '*' '*' >/dev/null
echo "Successfully configured kubectl"