Created
May 12, 2023 15:18
-
-
Save bradthurber/b10211c0d64ee2ab8b0f84d4ff357dee to your computer and use it in GitHub Desktop.
bash script to install or update the AWS CLI on Ubuntu
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/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 "make sure OS is up-to-date" | |
sudo apt update && sudo apt upgrade -y | |
sudo apt install unzip -y | |
echo "* Switching to new temporary tmp folder..." | |
pushd "$(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 | |
echo "Resuming at original directory" | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment