How to Install and Configure AWS CLI: A Complete Beginner’s Guide
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
Go to the AWS CLI Installer for Windows page.
Download the Windows .msi installer.
Open the downloaded file and follow the on-screen instructions to complete the installation.
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:
Open your Terminal.
Run the following command to install:
brew install awscli
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.
Open your Terminal and run:
sudo apt update sudo apt install awscli -y
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
Log in to the AWS Management Console.
Search for IAM in the search bar and click on IAM.
Click on Users and select the user you want to create keys for.
Click on the Security credentials tab.
Scroll down to Access keys and click Create access key.
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:
AWS Access Key ID: Enter the Access Key ID you copied earlier.
AWS Secret Access Key: Enter the Secret Access Key.
Default region name: Choose the AWS region you prefer (e.g.,
us-east-1
).Default output format: Choose
json
,text
, ortable
. 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
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
Secure Your Keys: Never share your Access Key ID and Secret Access Key. Treat them like your password.
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! ☁️💻
Subscribe to my newsletter
Read articles from Shivam Dubey directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by