Last active
May 9, 2024 15:46
-
-
Save ImIOImI/06a49a61f8634a8200565b4708826219 to your computer and use it in GitHub Desktop.
AWS Cloudshell init script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
defaultUser="ImIOImI" | |
defaultEmail="[email protected]" | |
rsaKeyFile=/home/cloudshell-user/.ssh/id_rsa | |
if [ ! -f "$rsaKeyFile" ]; then | |
#add rsa key | |
ssh-keygen -b 2048 -t rsa -f "$rsaKeyFile" -q -N "" | |
echo "Please copy the following into your GitHub profile here: https://github.com/settings/ssh/new | |
" | |
cat /home/cloudshell-user/.ssh/id_rsa.pub | |
read -r -p "Press any key to continue... | |
" | |
fi | |
read -p "GitHub Username: [$defaultUser]" uservar | |
read -p "GitHub Email: [$defaultEmail]" emailvar | |
uservar=${uservar:-${defaultUser}} | |
emailvar=${emailvar:-${defaultEmail}} | |
echo "Using... | |
username: $uservar | |
email: $emailvar | |
" | |
git config --global user.name $uservar | |
git config --global user.email $emailvar | |
git config --global credential.helper cache | |
sshConfig=<<EOD | |
Host github.com | |
User git | |
Hostname github.com | |
PreferredAuthentications publickey | |
IdentityFile /home/cloudshell-user/.ssh/id_rsa | |
EOD | |
echo $sshConfig >> /home/cloudshell-user/.ssh/config | |
chmod 600 /home/cloudshell-user/.ssh/config | |
eval $(ssh-agent -s) | |
ssh-add /home/cloudshell-user/.ssh/id_rsa | |
#get cloud extensions script | |
sudo ssh-keyscan -H github.com >> ~/.ssh/known_hosts | |
git clone [email protected]:ImIOImI/extensions-for-aws-managed-shells.git | |
#run cloud extensions script | |
cd extensions-for-aws-managed-shells | |
sh extensions-for-aws-managed-shells.sh | |
cd ~ | |
#add all the eks clusters you have access to | |
clusters=$(aws eks list-clusters | grep -oP '"(.*?)"' | sed 's/"clusters"//' | sed -e 's/^"//' -e 's/"$//') | |
echo $clusters | |
for val in $clusters; do | |
aws eks update-kubeconfig --name $val --alias $val | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment