How to Update AWS CLI via the Command Line
This guide is split into two sections:
1) how to install AWS CLI via the command line and
2) how to update AWS CLI via the command line. It explains how to do this for Linux, Windows, and macOS.
Part 1: Install CLI
Part 2: Update CLI
PART1: Install AWS CLI via Command Line
#1: Install the AWS CLI via the Command Line on Linux (Ubuntu) / WSL2
It’s good practice to check for existing installations of AWS CLI before installing. This can be done with
aws --version
Step 1: Update Package Lists
sudo apt update -y
Step 2: Install pip and unzip
sudo apt install python3-pip unzip -y
Step 3: Download and Install the AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && sudo ./aws/install
Step 4: Verify Installation
aws --version
#2: Install the AWS CLI via the Command Line on Windows using PowerShell
Step 1: Download the Installer
Remember you will need administrator privileges to perform these tasks:
Invoke-WebRequest -Uri https://awscli.amazonaws.com/AWSCLIV2.msi -OutFile .\AWSCLIV2.msi
Step 2: Run the Installer
Double-click the downloaded “AWSCLIV2.msi” file and follow the on-screen instructions.
Step 3: Verify Installation
Open a new PowerShell window and run:
aws --version
#3: Install the AWS CLI via the Command Line on MacOS (Terminal):
Step 1: Install Homebrew (if not already installed)
bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install the AWS CLI
brew install awscli
Step 3: Verify Installation
aws --version
PART 2: Update AWS CLI via Command Line
The update process is generally the same across operating systems:
#1: Update AWS CLI via the Command Line on Linux (Ubuntu)
Step 1: Remove Existing Version
pip3 install --upgrade awscli
Note: Use pip
instead of pip3
if your Python environment defaults to Python 2)
Step 2: Verify Update
aws --version
#2: Update AWS CLI via the Command Line on Windows (PowerShell)
Step 1: Update with MSI Installer
If you originally installed the AWS CLI using the MSI installer, the recommended way to update is by downloading and running the latest MSI installer again from the official AWS website. This will overwrite the older version with the updated one.
Remember you will need administrator privileges to perform these tasks:
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
Step 2: Update with pip (Alternative)
You can also try updating using pip (if you have it installed):
pip install --upgrade awscli
Step 3: Verify Update
aws --version
#3: Update AWS CLI via the Command Line on MacOS (Terminal)
Step 1: Update with brew
Brew, or Homebrew, is a free and open-source package manager for macOS (and Linux). It provides a simple way to install command-line tools and applications that are not bundled with the operating system.
brew upgrade awscli
Step 2: Verify Update
aws --version
Important Notes:
- Administrative Privileges: You’ll likely need administrative rights (e.g.,
sudo
on Linux/MacOS or running PowerShell as Administrator) to install or update system-wide. - Alternative Update Methods:
- Windows: If you installed using the MSI installer, you might need to download and re-run the latest installer to get updates.
- Linux: Some package managers (like
apt
) might offer update mechanisms (sudo apt install --only-upgrade awscli
).
- Shell Restart: After updating, it’s a good practice to restart your terminal or command prompt.
AWS CLI Q&A
What is the AWS CLI?
The AWS Command Line Interface (AWS CLI) is a unified tool used to manage Amazon Web Services (AWS) from the command line. It enables users to interact with AWS services and manage resources programmatically or via scripts. The AWS CLI is a powerful tool for developers, system administrators, and DevOps engineers to control AWS services without the need for a graphical interface.
Key Features:
- Unified Tool: AWS CLI allows users to control multiple AWS services from a single interface. You can manage compute resources, databases, storage, and more using commands.
- Automation and Scripting: AWS CLI supports automation by enabling users to write scripts that perform routine tasks, reducing the need for manual intervention. This is especially helpful for managing large infrastructures or for tasks such as deploying applications, monitoring resources, or configuring services.
- Cross-Platform: It works on multiple platforms, including Linux, macOS, and Windows. This makes it accessible to a broad range of users.
- Support for Multiple AWS Services: The AWS CLI supports virtually all AWS services, such as EC2, S3, Lambda, RDS, IAM, and more. This versatility allows you to manage nearly every aspect of AWS infrastructure from the command line.
- Direct Access to APIs: The AWS CLI provides direct access to AWS’s APIs, meaning the actions taken through the CLI closely mirror those you could perform programmatically via AWS SDKs.
- Credential Management: It integrates with AWS Identity and Access Management (IAM) to manage user access securely, allowing users to authenticate and authorize operations efficiently.
Common Use Cases:
- Resource Management: You can create, delete, or manage AWS resources like EC2 instances, S3 buckets, RDS databases, etc., using simple commands.
- Automation: Automating backup jobs, scaling instances, and managing infrastructure deployments via scripting and the AWS CLI.
- Monitoring: Query and retrieve logs, monitor services, or check resource statuses directly from the terminal.
Recent Comments