How to Install AWS CLI Version 2 on Ubuntu 22.04

The AWS Command Line Interface (CLI) is a powerful tool that allows you to interact with AWS services from your terminal or command prompt. With AWS CLI Version 2, you can manage cloud resources more efficiently and automate tasks using scripts. In this post, we’ll go through the steps required to install AWS CLI version 2 on Ubuntu 22.04, ensuring you have the latest features and enhancements available.

Prerequisites

Before we begin, ensure you have the following:

  • An Ubuntu 22.04 system.
  • Access to a terminal (you can use SSH if you’re working on a remote server).
  • Appropriate permissions to install packages and download the necessary files.

Step 1: Update Your System

It’s always a good practice to start with an updated system. Open your terminal and run the following commands:

sudo apt update
sudo apt upgrade -y

This ensures that you have the latest updates and patches.

Step 2: Install Required Dependencies

AWS CLI Version 2 requires curl for downloading the installation script and might require unzip if you’re going to extract ZIP files later on. You can install them using:

sudo apt install curl unzip -y

Step 3: Download the AWS CLI Version 2 Installer

AWS CLI version 2 provides a bundled installer that is easy to use. Download the installer with curl:

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

This command downloads the installation ZIP file from AWS’s official source.

Step 4: Unzip the Installer

Once the download is complete, unzip the installer using the following command:

unzip awscliv2.zip

This will create an installer directory containing the installation files.

Step 5: Run the Installer

Now, you can run the AWS CLI installer using the following command:

sudo ./aws/install

After the installation completes, it should inform you that AWS CLI version 2 has been installed successfully.

Step 6: Verify the Installation

To confirm that AWS CLI has been installed correctly, run the following command:

aws --version

You should see an output that resembles:

aws-cli/2.x.x Python/3.x.x Linux/x86_64 source/xxxxxx

This output indicates the installed version of AWS CLI along with the Python version it’s using.

Step 7: Configure AWS CLI

Before using the AWS CLI, you need to configure it with your AWS credentials. Run the following command:

aws configure

You will be prompted to enter:

  1. AWS Access Key ID: Your unique identifier for AWS.
  2. AWS Secret Access Key: Your secret key for authentication with AWS.
  3. Default region name: The AWS region you want to send requests to (e.g., us-west-2).
  4. Default output format: The format in which you want AWS CLI to return results (e.g., jsonyamltext, etc.).

Follow the prompts to complete the configuration.

Step 8: Clean Up (Optional)

Once the installation is complete, you may want to clean up by removing the downloaded ZIP file:

rm awscliv2.zip

Conclusion

Congratulations! You have successfully installed AWS CLI version 2 on your Ubuntu 22.04 system. With AWS CLI at your fingertips, you can now manage your AWS resources from the terminal, automate workflows, and streamline your development processes.

To learn more about the capabilities of AWS CLI, check out the official AWS CLI documentation to get started with various commands and functionalities. Happy cloud computing!

Leave a Comment