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

Bash
aws --version

Step 1: Update Package Lists

Bash
sudo apt update -y

Step 2: Install pip and unzip

Bash
sudo apt install python3-pip unzip -y

Step 3: Download and Install the AWS CLI

Bash
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && sudo ./aws/install 

Step 4: Verify Installation

Bash
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:

PowerShell
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:

PowerShell
aws --version 

#3: Install the AWS CLI via the Command Line on MacOS (Terminal):

Step 1: Install Homebrew (if not already installed)

Bash
bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2: Install the AWS CLI

Bash
brew install awscli

Step 3: Verify Installation

Bash
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

Bash
pip3 install --upgrade awscli 

Note: Use pip instead of pip3 if your Python environment defaults to Python 2)

Step 2: Verify Update

Bash
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:

PowerShell
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):

PowerShell
pip install --upgrade awscli 

Step 3: Verify Update

PowerShell
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.

Bash
brew upgrade awscli

Step 2: Verify Update

Bash
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:

  1. 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.
  2. 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.
  3. Cross-Platform: It works on multiple platforms, including Linux, macOS, and Windows. This makes it accessible to a broad range of users.
  4. 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.
  5. 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.
  6. 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.
Elsewhere On TurboGeek:  How to install Microsoft SQL 2012 R2

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »