Skip to content
Welcome To Charanjit Cheema Blog

Welcome To Charanjit Cheema Blog

An Open Source and Cloud Blog

Menu
  • Home
  • About Me!
  • Way to my Technical Blog
  • Contact me
  • Privacy Policy
Menu

How to install and configure AWS CLI

Posted on April 27, 2018January 31, 2025 by Charanjit Cheema

The AWS has launched AWS Command Line Interface (CLI) unified tool to manage your whole AWS services from the command line and automate them through scripts.

You can install AWS CLI on your Linux or Windows machine for managing AWS services from command line.

In this post I have demonstrated how to install and configure the AWS CLI tool and its prerequisite in CentOS Linux. For using AWS CLI on my base Ubuntu 16.04 machine I have made a one CentOS 7 Virtual Machine by using KVM Virtualisation.

On below Python versions AWS CLI can work:

  • 2.6.5 and greater
  • 2.7.x and greater
  • 3.3.x and greater
  • 3.4.x and greater
  • 3.5.x and greater
  • 3.6.x and greater

PIP Package checking and installation before installing AWS CLI:

For installing AWS CLI PIP Package should be installed in your Linux machine. PIP is a special program used to install Python packages to your system. Pip is sometimes included automatically when Python is installed to your system, and sometimes you have to install it yourself. As AWS CLI package is Python based hence PIP package is a mandatory prerequisite package which should be available in your Linux machine

  • To check if Python PIP is installed in CentOS 7 VM type command pip –version:
[charanjit@centos7srv1 ~]$ pip --version
pip 7.0.3 from /usr/local/lib/python3.5/dist-packages (python 3.5)
[charanjit@centos7srv1 ~]$
  • If PIP package is not installed in Linux machine then PIP Package need to download from Link: https://bootstrap.pypa.io/get-pip.py and install:
[charanjit@centos7srv1 ~]$ wget https://bootstrap.pypa.io/get-pip.py
--2018-04-27 06:10:43-- https://bootstrap.pypa.io/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.8.175, 2a04:4e42:2::175
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.8.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1642329 (1.6M) [text/x-python]
Saving to: ‘get-pip.py.1’

100%[======================================>] 16,42,329 2.59MB/s in 0.6s

2018-04-27 06:10:44 (2.59 MB/s) - ‘get-pip.py.1’ saved [1642329/1642329]

[charanjit@centos7srv1 ~]$ 
[charanjit@centos7srv1 ~]$ sudo python get-pip.py
Collecting pip
  Downloading pip-7.1.2-py2.py3-none-any.whl (1.1MB)
    100% |████████████████████████████████| 1.1MB 448kB/s 
Collecting setuptools
  Downloading setuptools-18.4-py2.py3-none-any.whl (462kB)
    100% |████████████████████████████████| 462kB 676kB/s 
Collecting wheel
  Downloading wheel-0.26.0-py2.py3-none-any.whl (63kB)
    100% |████████████████████████████████| 65kB 912kB/s 
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-7.1.2 setuptools-18.4 wheel-0.26.0
[charanjit@centos7srv1 ~]$

 

Installation of AWS CLI:

  • Install the AWS CLI package from PIP.
sudo pip install awscli
  •  Post installation check the AWS CLI version:
[charanjit@centos7srv1 ~]$ aws --version
aws-cli/1.14.68 Python/3.5 Linux/3.10.0-693.el7.x86_64 botocore/1.9.21
[charanjit@centos7srv1 ~]$

 

Configuration of AWS CLI:

  • Open the IAM console.
  • In the navigation pane of the console, choose Users.
  • Choose your IAM user name (not the check box).
  • Choose the Security credentials tab and then choose Create access key.
  • To see the new access key, choose Show. Your credentials will look something like this:
    • Access key ID: AKIAIOSFODNN7EXAMPLE
    • Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
  • To download the key pair, choose Download .csv file. Store the keys in a secure location.
  • Configure the AWS connection with same Access Key ID and Secret Access Key.
[charanjit@centos7srv1 ~]$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json
[charanjit@centos7srv1 ~] 
  • Now do post configuration check with command: aws ec2 describe-instances –output table

[charanjit@centos7srv1 ~]$ aws ec2 describe-instances --output table
------------------------------------------------------------------------------------
| DescribeInstances |
+----------------------------------------------------------------------------------+
|| Reservations ||
|+---------------------------------+----------------------------------------------+|
|| OwnerId | 882323792697 ||
|| ReservationId | r-037769699a0f3c458 ||
|+---------------------------------+----------------------------------------------+|
||| Instances |||
||+--------------------------+---------------------------------------------------+||
||| AmiLaunchIndex | 0 |||
||| Architecture | x86_64 |||
||| ClientToken | |||
||| EbsOptimized | False |||
||| EnaSupport | True |||
||| Hypervisor | xen |||
||| ImageId | ami-03291866 |||
||| InstanceId | i-0687b720a702dd60e |||
||| InstanceType | t2.micro |||
||| KeyName | EFS_test |||
||| LaunchTime | 2018-04-21T07:14:17.000Z |||
||| PrivateDnsName | ip-172-31-45-97.us-east-2.compute.internal |||
||| PrivateIpAddress | 172.31.45.97 |||
||| PublicDnsName | |||
||| RootDeviceName | /dev/sda1 |||
||| RootDeviceType | ebs |||
||| SourceDestCheck | True |||
||| StateTransitionReason | |||
||| SubnetId | subnet-f65454bb |||
||| VirtualizationType | hvm |||
||| VpcId | vpc-87c9a8ef |||
||+--------------------------+---------------------------------------------------+||
|||| BlockDeviceMappings ||||
|||+--------------------------------------+-------------------------------------+|||
|||| DeviceName | /dev/sda1 ||||
|||+--------------------------------------+-------------------------------------+|||
||||| Ebs |||||
||||+--------------------------------+-----------------------------------------+||||
||||| AttachTime | 2018-04-21T07:14:18.000Z |||||
||||| DeleteOnTermination | True |||||
||||| Status | attached |||||
||||| VolumeId | vol-095714007eee0a2b7 |||||
||||+--------------------------------+-----------------------------------------+||||
|||| Monitoring ||||
|||+-------------------------------+--------------------------------------------+|||
|||| State | disabled ||||
|||+-------------------------------+--------------------------------------------+|||
|||| NetworkInterfaces ||||
|||+-----------------------+----------------------------------------------------+|||
|||| Description | ||||
|||| MacAddress | 0a:62:09:63:93:8e ||||
|||| NetworkInterfaceId | eni-0d372b2a360608244 ||||
|||| OwnerId | 882323792697 ||||
|||| PrivateDnsName | ip-172-31-45-97.us-east-2.compute.internal ||||
|||| PrivateIpAddress | 172.31.45.97 ||||
|||| SourceDestCheck | True ||||
|||| Status | in-use ||||
|||| SubnetId | subnet-f65454bb ||||
|||| VpcId | vpc-87c9a8ef ||||
|||+-----------------------+----------------------------------------------------+|||
||||| Attachment |||||
||||+------------------------------+-------------------------------------------+||||
||||| AttachTime | 2018-04-21T07:14:17.000Z |||||
||||| AttachmentId | eni-attach-062760aa0aed97ec4 |||||
||||| DeleteOnTermination | True |||||
||||| DeviceIndex | 0 |||||
||||| Status | attached |||||
||||+------------------------------+-------------------------------------------+||||
||||| Groups |||||
||||+-------------------------+------------------------------------------------+||||
||||| GroupId | sg-051aad8c2fc42a16f |||||
||||| GroupName | EFS_test |||||
||||+-------------------------+------------------------------------------------+||||
||||| PrivateIpAddresses |||||
||||+---------------------+----------------------------------------------------+||||
||||| Primary | True |||||
||||| PrivateDnsName | ip-172-31-45-97.us-east-2.compute.internal |||||
||||| PrivateIpAddress | 172.31.45.97 |||||
||||+---------------------+----------------------------------------------------+||||
|||| Placement ||||
|||+--------------------------------------------+-------------------------------+|||
|||| AvailabilityZone | us-east-2c ||||
|||| GroupName | ||||
|||| Tenancy | default ||||
|||+--------------------------------------------+-------------------------------+|||
|||| SecurityGroups ||||
|||+-------------------------+--------------------------------------------------+|||
|||| GroupId | sg-051aad8c2fc42a16f ||||
|||| GroupName | EFS_test ||||
|||+-------------------------+--------------------------------------------------+|||
|||| State ||||
|||+-------------------------------+--------------------------------------------+|||
|||| Code | 80 ||||
|||| Name | stopped ||||
|||+-------------------------------+--------------------------------------------+|||
|||| StateReason ||||
|||+---------+------------------------------------------------------------------+|||
|||| Code | Client.InstanceInitiatedShutdown ||||
|||| Message| Client.InstanceInitiatedShutdown: Instance initiated shutdown ||||
|||+---------+------------------------------------------------------------------+|||
|||| Tags ||||
|||+-----------------------+----------------------------------------------------+|||
|||| Key | Name ||||
|||| Value | Redhat-EFS-Test ||||
|||+-----------------------+----------------------------------------------------+|||
|| Reservations ||
|+---------------------------------+----------------------------------------------+|
|| OwnerId | 882323792697 ||
|| ReservationId | r-06a0c03db6cfce40e ||
|+---------------------------------+----------------------------------------------+|
||| Instances |||
||+--------------------------+---------------------------------------------------+||
||| AmiLaunchIndex | 0 |||
||| Architecture | x86_64 |||
||| ClientToken | |||
||| EbsOptimized | False |||
||| EnaSupport | True |||
||| Hypervisor | xen |||
||| ImageId | ami-57d3e732 |||
||| InstanceId | i-0b0536f64d83bed49 |||
||| InstanceType | t2.micro |||
||| KeyName | EFS_test |||
||| LaunchTime | 2018-04-21T06:48:21.000Z |||
||| PrivateDnsName | ip-172-31-40-45.us-east-2.compute.internal |||
||| PrivateIpAddress | 172.31.40.45 |||
||| PublicDnsName | |||
||| RootDeviceName | /dev/sda1 |||
||| RootDeviceType | ebs |||
||| SourceDestCheck | True |||
||| StateTransitionReason | |||
||| SubnetId | subnet-f65454bb |||
||| VirtualizationType | hvm |||
||| VpcId | vpc-87c9a8ef |||
||+--------------------------+---------------------------------------------------+||
|||| BlockDeviceMappings ||||
|||+--------------------------------------+-------------------------------------+|||
|||| DeviceName | /dev/sda1 ||||
|||+--------------------------------------+-------------------------------------+|||
||||| Ebs |||||
||||+--------------------------------+-----------------------------------------+||||
||||| AttachTime | 2018-04-21T05:42:35.000Z |||||
||||| DeleteOnTermination | True |||||
||||| Status | attached |||||
||||| VolumeId | vol-0822eb1d30ac8e030 |||||
||||+--------------------------------+-----------------------------------------+||||
|||| Monitoring ||||
|||+-------------------------------+--------------------------------------------+|||
|||| State | disabled ||||
|||+-------------------------------+--------------------------------------------+|||
|||| NetworkInterfaces ||||
|||+-----------------------+----------------------------------------------------+|||
|||| Description | ||||
|||| MacAddress | 0a:e5:3a:9f:5e:d6 ||||
|||| NetworkInterfaceId | eni-0923d9615adb1b3b7 ||||
|||| OwnerId | 882323792697 ||||
|||| PrivateDnsName | ip-172-31-40-45.us-east-2.compute.internal ||||
|||| PrivateIpAddress | 172.31.40.45 ||||
|||| SourceDestCheck | True ||||
|||| Status | in-use ||||
|||| SubnetId | subnet-f65454bb ||||
|||| VpcId | vpc-87c9a8ef ||||
|||+-----------------------+----------------------------------------------------+|||
||||| Attachment |||||
||||+------------------------------+-------------------------------------------+||||
||||| AttachTime | 2018-04-21T05:42:35.000Z |||||
||||| AttachmentId | eni-attach-0dac92554553dff3b |||||
||||| DeleteOnTermination | True |||||
||||| DeviceIndex | 0 |||||
||||| Status | attached |||||
||||+------------------------------+-------------------------------------------+||||
||||| Groups |||||
||||+-------------------------+------------------------------------------------+||||
||||| GroupId | sg-051aad8c2fc42a16f |||||
||||| GroupName | EFS_test |||||
||||+-------------------------+------------------------------------------------+||||
||||| PrivateIpAddresses |||||
||||+---------------------+----------------------------------------------------+||||
||||| Primary | True |||||
||||| PrivateDnsName | ip-172-31-40-45.us-east-2.compute.internal |||||
||||| PrivateIpAddress | 172.31.40.45 |||||
||||+---------------------+----------------------------------------------------+||||
|||| Placement ||||
|||+--------------------------------------------+-------------------------------+|||
|||| AvailabilityZone | us-east-2c ||||
|||| GroupName | ||||
|||| Tenancy | default ||||
|||+--------------------------------------------+-------------------------------+|||
|||| SecurityGroups ||||
|||+-------------------------+--------------------------------------------------+|||
|||| GroupId | sg-051aad8c2fc42a16f ||||
|||| GroupName | EFS_test ||||
|||+-------------------------+--------------------------------------------------+|||
|||| State ||||
|||+-------------------------------+--------------------------------------------+|||
|||| Code | 80 ||||
|||| Name | stopped ||||
|||+-------------------------------+--------------------------------------------+|||
|||| StateReason ||||
|||+---------+------------------------------------------------------------------+|||
|||| Code | Client.InstanceInitiatedShutdown ||||
|||| Message| Client.InstanceInitiatedShutdown: Instance initiated shutdown ||||
|||+---------+------------------------------------------------------------------+|||
|||| Tags ||||
|||+-------------------------+--------------------------------------------------+|||
|||| Key | Value ||||
|||+-------------------------+--------------------------------------------------+|||
|||| Name | Suse-EFS-test ||||
|||| Name | EFS test ||||
|||+-------------------------+--------------------------------------------------+|||
[charanjit@centos7srv1 ~]$

Loading

  • Author
  • Recent Posts
Charanjit Cheema
Follow him
Charanjit Cheema
Charanjit is currently working as a Cloud Architect at Mphasis, with 17 years of experience in IT infrastructure projects, implementation, and support. While his main role is as a DevOps engineer, he holds a Cloud Architect position and has strong skills in cloud technologies and automation. His expertise includes Terraform, Ansible, AWS, Azure DevOps, Azure Cloud, VMware, and Linux systems.

Charanjit is passionate about automating tasks and improving processes. He uses tools like Terraform and Azure DevOps to build and manage cloud infrastructure and streamline deployment. He also enjoys using Shell scripts and Ansible playbooks to make systems run more efficiently.

In his free time, Charanjit enjoys learning about new technologies and sharing his knowledge through his blog. When he’s not working, he likes listening to music, having a cup of coffee, and relaxing in nature.

You can connect with Charanjit on Twitter, Facebook, LinkedIn, or email him at charanjit.cheema@cjcheema.com.
Charanjit Cheema
Follow him
Latest posts by Charanjit Cheema (see all)
  • How to optimize the performance of Ansible Automation Platform or Ansible Tower - July 16, 2023
  • How to fix code and text file linting errors with the help of Visual Studio Code - June 27, 2023
  • How to migrate existing WordPress blog from AWS EC2 instance to Amazon Lightsail - May 29, 2023

Like this:

Like Loading...

Related

5 thoughts on “How to install and configure AWS CLI”

  1. Azad Ahmed says:
    April 27, 2018 at 12:18 pm

    Good Charan. Keep it up.

    Loading...
    Reply
    1. Charanjit Cheema says:
      May 11, 2018 at 1:32 am

      Thanks Azad your valuable comments are really motivating me!!

      Loading...
      Reply
  2. Paramjit Singh says:
    April 28, 2018 at 1:30 am

    Very informative topic. Thanks for sharing it.

    Loading...
    Reply
    1. Charanjit Cheema says:
      May 11, 2018 at 1:33 am

      Thank you!

      Loading...
      Reply
  3. rohit Mishra says:
    October 28, 2018 at 10:43 pm

    Grt discription , it’s help me a lot …highly thnx for dis

    Loading...
    Reply

Leave a Reply to rohit MishraCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Tags

AWS Cloud Computing Dockers Networking Open Networking OpenSource RHEL-CentOS SDN Server Hardware SLES tcpdump Ubuntu WSL

Follow me @

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 2 other subscribers

Recent Posts

  • How to Deploy Docker Containers with NGINX on AWS EC2 Using Ansible and GitHub Actions
  • No More DynamoDB! Use Native S3 locking for Terraform State
  • How to Bring and Manage Manually Created AWS Resources Under Terraform Management
  • Iterating Cloud Resource Provisioning Using Terraform Count and For_Each Meta-Arguments
  • Terraform and Ansible Collaboration for AWS Cloud Deployment

Recent Comments

  1. Charanjit Singh on Terraform and Ansible Collaboration for AWS Cloud Deployment
  2. christinatodd2020aeaa798563 on Terraform and Ansible Collaboration for AWS Cloud Deployment
  3. Charanjit Singh on How to Set password policy in CentOS or RHEL system
  4. SAURABH on How to recover or rebuild initramfs in CentOS 7 Linux
  5. Sangita on How to Set password policy in CentOS or RHEL system

Archives

  • April 2025
  • February 2025
  • January 2025
  • August 2024
  • July 2024
  • June 2024
  • January 2024
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • September 2022
  • August 2022
  • July 2020
  • May 2020
  • February 2020
  • November 2019
  • June 2019
  • May 2019
  • March 2019
  • February 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • June 2018
  • May 2018
  • April 2018

Categories

  • Automation
  • Cloud Computing
  • Coding
  • CyberSecurity
  • Networking
  • OpenSource
  • RHEL-CentOS
  • Server Hardware
  • SLES
  • Technical Blog
  • Ubuntu
  • WSL

Blog Stats

  • 18,353 hits
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Home
  • About Me!
  • Way to my Technical Blog
  • Contact me
  • Privacy Policy
© 2025 Welcome To Charanjit Cheema Blog | Powered by Superbs Personal Blog theme
%d