Skip to content

Instantly share code, notes, and snippets.

@TeemuKoivisto
Last active June 30, 2024 16:26
Show Gist options
  • Save TeemuKoivisto/a99d51a2e4d86ebefad353ab2d4273ae to your computer and use it in GitHub Desktop.
Save TeemuKoivisto/a99d51a2e4d86ebefad353ab2d4273ae to your computer and use it in GitHub Desktop.
Installs AWS CLI v2 with Bash for Linux x86 / ARM
#!/bin/bash
# or for alpine #!/bin/sh
########################################################
# Installs AWS CLI v2 https://docs.aws.amazon.com/cli/ #
########################################################
# Needs curl or wget and unzip installed
# If you are using Alpine, you should use apk directly (because reasons https://github.com/aws/aws-cli/issues/4971)
# apk add aws-cli=2.13.5-r0
get_downloader() {
if [ "$(command -v curl)" ]; then
echo "curl"
elif [ "$(command -v wget)" ]; then
echo "wget"
else
echo ""
fi
}
get_aws_distro() {
if [ -z $(uname -a | grep x86) ]; then
echo "x86_64"
else
echo "aarch64"
fi
}
DOWNLOADER=$(get_downloader)
DISTRO=$(get_aws_distro)
if [ -z $DOWNLOADER ]; then
echo -e "\033[42m(install_awscli_v2)\033[0m No curl or wget installed"
exit 1
fi
if [ $DOWNLOADER == "curl" ]; then
curl "https://awscli.amazonaws.com/awscli-exe-linux-$DISTRO.zip" -o "/tmp/awscliv2.zip" && \
yes | unzip "/tmp/awscliv2.zip" -d /tmp && \
/tmp/aws/install --update
else
wget -O "/tmp/awscliv2.zip" "https://awscli.amazonaws.com/awscli-exe-linux-$DISTRO.zip" && \
yes | unzip "/tmp/awscliv2.zip" -d /tmp && \
/tmp/aws/install --update
fi
aws --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment