How to Install and Configure AWS CLI: A Complete Beginner’s Guide

Shivam DubeyShivam Dubey
4 min read

If you want to manage AWS services directly from your computer's terminal, the AWS Command Line Interface (CLI) is the tool for you! It’s a powerful utility that allows you to perform operations on AWS resources using simple commands. This guide will help you install the AWS CLI, and then walk you through configuring it with your AWS account keys.


📥 Part 1: Installing AWS CLI

Step 1: Check If AWS CLI Is Already Installed

Before installing, check if the AWS CLI is already on your system. Open your Command Prompt (Windows) or Terminal (macOS/Linux) and type:

aws --version

If you see a version number like aws-cli/2.13.0, it’s already installed. If not, follow the steps below.


Step 2: Installing AWS CLI on Windows

  1. Go to the AWS CLI Installer for Windows page.

  2. Download the Windows .msi installer.

  3. Open the downloaded file and follow the on-screen instructions to complete the installation.

  4. After installation, verify it by typing:

     aws --version
    

    You should see the AWS CLI version number.


Step 3: Installing AWS CLI on macOS

On macOS, you can use Homebrew to install the AWS CLI:

  1. Open your Terminal.

  2. Run the following command to install:

     brew install awscli
    
  3. Verify the installation:

     aws --version
    

If you don’t have Homebrew installed, you can download the AWS CLI installer directly from the AWS CLI download page.


Step 4: Installing AWS CLI on Linux

On Linux, you can use the package manager (e.g., apt for Ubuntu) or install directly.

  1. Open your Terminal and run:

     sudo apt update
     sudo apt install awscli -y
    
  2. Verify the installation:

     aws --version
    

If your Linux distribution doesn’t support this method, you can use the bundled installer from the AWS CLI documentation.


Step 5: Upgrading AWS CLI

If you already have an older version of the AWS CLI, you can upgrade it:

  • On Windows: Download and run the latest installer.

  • On macOS (Homebrew):

      brew upgrade awscli
    
  • On Linux:

      sudo apt update
      sudo apt upgrade awscli
    

🔑 Part 2: Configuring AWS CLI with Your Access Keys

Now that you have the AWS CLI installed, you need to configure it with your AWS Access Key ID and Secret Access Key.

Step 1: Generate Access Keys

  1. Log in to the AWS Management Console.

  2. Search for IAM in the search bar and click on IAM.

  3. Click on Users and select the user you want to create keys for.

  4. Click on the Security credentials tab.

  5. Scroll down to Access keys and click Create access key.

  6. Copy the Access Key ID and Secret Access Key, or download the .csv file.

Note: Keep these keys secure! They are like passwords to your AWS account.


Step 2: Configure AWS CLI

In your terminal, run:

aws configure

You will be prompted to enter:

  1. AWS Access Key ID: Enter the Access Key ID you copied earlier.

  2. AWS Secret Access Key: Enter the Secret Access Key.

  3. Default region name: Choose the AWS region you prefer (e.g., us-east-1).

  4. Default output format: Choose json, text, or table. For beginners, json is the easiest to read.

Example:

AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: json

Step 3: Verify Your Configuration

To ensure everything is set up correctly, run:

aws sts get-caller-identity

If configured correctly, you will see output like this:

{
    "UserId": "AIDAEXAMPLEID",
    "Account": "123456789012",
    "Arn": "arn:aws:iam::123456789012:user/your-username"
}

⚙️ Additional Tips

  1. Multiple Profiles: If you manage multiple AWS accounts, use different profiles by running:

     aws configure --profile myprofile
    

    Use this profile in commands with the --profile flag:

     aws s3 ls --profile myprofile
    
  2. Secure Your Keys: Never share your Access Key ID and Secret Access Key. Treat them like your password.

  3. Rotate Keys Regularly: For better security, generate new keys and delete old ones periodically.


🎯 Conclusion

Congratulations! 🎉 You’ve successfully installed and configured the AWS CLI on your computer. With the AWS CLI, you can now perform powerful actions on your AWS resources directly from your terminal. This will save you time and help automate your workflows.

For more advanced usage, check out the AWS CLI User Guide. Start with simple commands and gradually explore more features as you get comfortable.

Happy cloud managing! ☁️💻

0
Subscribe to my newsletter

Read articles from Shivam Dubey directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shivam Dubey
Shivam Dubey