Last active
May 14, 2025 20:35
-
-
Save alexolinux/9d470cf64b7bc88318ba0f137c2c8f24 to your computer and use it in GitHub Desktop.
aws-cli installation
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 | |
ARCH=$(arch) | |
# Check Function | |
check_aws() { | |
if [ "$?" -eq 0 ]; then | |
echo "AWS Cli has been installed successfuly." | |
aws --version | |
fi | |
} | |
# Function to check for a package and install it if missing | |
install_if_missing() { | |
PACKAGE_NAME=$1 | |
if ! command -v "$PACKAGE_NAME" &>/dev/null; then | |
echo "$PACKAGE_NAME is not installed. Installing..." | |
if [ -f /etc/debian_version ]; then | |
sudo apt update && sudo apt install -y "$PACKAGE_NAME" | |
elif [ -f /etc/centos-release ] || [ -f /etc/redhat-release ]; then | |
if command -v dnf &>/dev/null; then | |
sudo dnf install -y "$PACKAGE_NAME" | |
else | |
sudo yum install -y "$PACKAGE_NAME" | |
fi | |
else | |
echo "Unsupported Linux distribution." | |
exit 1 | |
fi | |
else | |
echo "$PACKAGE_NAME is already installed." | |
fi | |
} | |
# Ensure required packages (curl, unzip) are installed | |
install_if_missing curl | |
install_if_missing unzip | |
# Proceed with AWS CLI installation based on architecture | |
if [ "${ARCH}" = "x86_64" ]; then | |
cd /tmp | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
sudo ./aws/install | |
check_aws | |
elif [ "${ARCH}" = "aarch64" ]; then | |
cd /tmp | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
sudo ./aws/install | |
check_aws | |
else | |
echo "Architecture is not supported." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html