How to Install and Update the AWS CLI (Windows, macOS, & Linux Guide)

The AWS Command Line Interface (CLI) is an essential tool for any developer, sysadmin, or DevOps engineer working with Amazon Web Services. It allows you to control and automate hundreds of AWS services directly from your terminal, streamlining everything from resource management to complex deployment scripts.

This guide provides clear, step-by-step instructions for installing and updating the latest version of AWS CLI (v2) on Windows, macOS, and Linux using only the command line. We’ll focus on the official, recommended methods to ensure a stable and reliable setup.


Install & Update AWS CLI on Windows

The recommended method for Windows is using the official MSI installer, which can be downloaded and run silently via PowerShell. You will need administrator privileges.

1. Check for an Existing Installation (Optional)

Open a new Command Prompt or PowerShell window and run:

aws --version

If the CLI is installed, this command will return the installed version. If not, you’ll see an error.

2. Install or Update the AWS CLI

This single set of commands works for both a fresh installation and for updating an existing one. The MSI installer automatically handles overwriting the old version with the new one.

  • Open PowerShell as Administrator.
  • Download the latest official AWS CLI MSI installer:
Invoke-WebRequest -Uri "https://awscli.amazonaws.com/AWSCLIV2.msi" -OutFile "AWSCLIV2.msi"

  • Run the installer silently: The /quiet flag installs the CLI for all users without showing a graphical interface.
msiexec.exe /i "AWSCLIV2.msi" /quiet 

3. Verify the Installation

Important: You must close and reopen your PowerShell or Command Prompt window for the new PATH to take effect.

aws --version

The output should now show the latest version, for example: aws-cli/2.17.9 Python/3.11.8 Windows/10 exe/AMD64.


Install & Update AWS CLI on macOS

For macOS, the most common and straightforward method is using the Homebrew package manager.

1. Check for an Existing Installation (Optional)

Open a new Terminal window and check if the CLI is already installed:

aws --version

2. Install or Update with Homebrew

If you don’t have Homebrew, you can install it with a single command from their official website:

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

  • To install the AWS CLI, run the following brew command. Homebrew automatically taps the correct formula for the latest version of AWS CLI v2.

brew install awscli

  • To update an existing Homebrew installation, simply run the upgrade command:

brew upgrade awscli

3. Verify the Installation

Open a new terminal session to ensure you’re using the updated version and run:

aws --version


Install & Update AWS CLI on Linux

AWS recommends using the official bundled installer for all Linux distributions, including Ubuntu, Amazon Linux, and CentOS. This method avoids potential conflicts with system Python packages.

1. Check for an Existing Installation (Optional)

In your terminal, check for a pre-existing version of the CLI:

aws --version

2. Install or Update the AWS CLI

These steps download the official installer, unzip it, and run the installation script. The script automatically handles both new installs and updates.

  • Download the latest installer package. We use curl to fetch the 64-bit Linux package.

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

  • Unzip the installer. If you don’t have unzip, install it first with sudo apt install unzip or sudo yum install unzip.

unzip awscliv2.zip
  • Run the install script. Use sudo to install the CLI to the default location (/usr/local/aws-cli), which makes it available to all users. The --update flag will replace an existing installation with the version you just downloaded.

sudo ./aws/install --update

3. Verify the Installation

Check the version to confirm the process was successful.

aws --version

After installation or an update, you can safely remove the files you downloaded:

rm -f awscliv2.zip
rm -rf aws

Next Steps: Configure Your Credentials

Once the AWS CLI is installed, your next step is to configure it with your security credentials. Run the following command and follow the prompts:

aws configure

You will be asked for your:

  • AWS Access Key ID
  • AWS Secret Access Key
  • Default region name (e.g., us-east-1)
  • Default output format (e.g., json)

This creates a credentials file that the CLI uses to authenticate your requests to AWS services.

Elsewhere On TurboGeek:  How to Structure Your Terraform Code

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 ยป