Last active
May 23, 2023 16:02
-
-
Save hekmon/9c8394efee0929fe0f07a0f5a16215e3 to your computer and use it in GitHub Desktop.
AWS CLI v2 - install and update on a bash based linux system
This file contains 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/bash -e | |
# https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html#cliv2-linux-install | |
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-completion.html | |
echo "* Switching to tmp folder..." | |
cd "$(mktemp -d)" | |
echo | |
echo "* Downloading the AWS cli..." | |
wget -q "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -O awscliv2.zip | |
echo | |
echo "* Unzipping it..." | |
unzip -q awscliv2.zip | |
echo | |
if [ -f /usr/local/bin/aws ]; then | |
echo "* Current version:" | |
/usr/local/bin/aws --version | |
echo "* Updating..." | |
sudo ./aws/install --update | |
else | |
echo "* Installing..." | |
sudo ./aws/install | |
fi | |
echo | |
echo "* Install and activate bash autocompletion..." | |
if ! grep -q aws_completer ~/.bashrc; then | |
echo "complete -C '/usr/local/bin/aws_completer' aws" | tee -a ~/.bashrc | |
fi | |
complete -C '/usr/local/bin/aws_completer' aws | |
cd - | |
echo | |
echo "* Installed version:" | |
/usr/local/bin/aws --version | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment