Install AWS CLI

How to Install AWS CLI? Step by Step Configuration Guide

In this step-by-step guide, you will learn how to install AWS CLI and configure the CLI to connect to AWS and execute the CLI commands.

AWS CLI supports the following platforms.

  1. Linux
  2. MAC
  3. WIndows.

We have added the commands to install AWS CLI on all three platforms in the way.

Install AWS CLI on Linux

If you are using Linux based system, you just need the execute the following commands.

Note: Ensure you have unzip utility installed on your Linux system

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

To validate the CLI installation, execute the CLI version command.

aws --version

To know the location of the binary, execute the following command. Usually it would be /usr/local/bin/aws

which aws

Install AWS CLI on MAC

AWS MAC CLI installation is very easy. You just need to install it using brew.

If you don’t have homebrew, install it using the following command.

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

Then install the aws cli.

brew install awscli

Install AWS CLI on Windows

For windows download the aws cli MSI file and install it.

You can download the MSI file from here https://awscli.amazonaws.com/AWSCLIV2.msi

Configure AWS CLI

Before starting the configuration, you should have the AWS access key and secret key for your user. If you dont have these details, you can create one from the IAM console under your user name.

Go to “My Security Credentials” Under your Account Name in AWS Console.

Run the configure command.

aws configure

It will ask for the AWS access key, secret key, region, and default output format. provide the details you prefer.

For example,

[email protected]:~$ aws configure
AWS Access Key ID : [****************7PFK]
AWS Secret Access Key : [****************tEuh]
Default region name : us-west-2
Default output format : JSON

AWS CLI Config File Location

When you run the aws configure command, a config file and credential file gets creates in the $HOME/.aws location

The config file will have details except the access key and secret key.

The credentials file will have the access key and secret key.

When you execute an AWS CLI command, the CLI uses the config and credential file to authenticate against AWS API. You can change the values of these files with new values anytime you change the credentials or default region.

Verify AWS CLI Authentication

You can verify the AWS CLI authentication by executing any command that interacts with AWS API.

For example, we will list instances using the AWS CLI command.

aws ec2 describe-instances

Now let’s create an instance using the CLI. Replace the values with values that match your AWS account.

aws ec2 run-instances \
    --image-id ami-0d70546e43a941d70 \
    --count 1 \
    --instance-type t2.micro \
    --key-name bibin-server \
    --security-group-ids sg-00cf38e1e1799e52a \
    --subnet-id subnet-042384c724edd40c0 \
    --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=cli-server}]' 'ResourceType=volume,Tags=[{Key=Name,Value=cli-server-disk}]'

AWS CLI FAQs

What is AWS CLI used for?

AWS CLI is used to manage AWS resources using the CLI utility. With AWS CLI you can authenticate to AWS services and manage them using the CLI commands. AWS CLI is written in python and it can be installed on Linux, MAC, and Windows systems.

Where is AWS CLI installed?

When you install AWS CLI, it gets installed as per the operating systems. In Linux & MAC systems, it gets installed in /usr/local/bin/aws. For windows based systems, it gets installed in C:\Program Files\Amazon\AWSCLI (64-bit version) or C:\Program Files (x86)\Amazon\AWSCLI location.

What is the difference between AWS CLI and console?

With AWS CLI, you can have terminal-only access to AWS services. Meaning you have to use commands to list and manage AWS services. With AWS console, you can manage AWS resources from a web UI.

Conclusion

In this blog, we learned the easy ways to install AWS CLI utility and configure it to authenticate to an AWS account.

Next, we will see how to use the AWS CLI setup to create AWS resources.

Install AWS CLI

Other Interesting Blogs

Leave a Comment

4 Shares
Share via
Copy link
Powered by Social Snap