How to Install and Configure AWS CLI (Amazon Web Services Command Line Interface)
Before you start using the Amazon Web Services Command Line Interface, you must have an AWS account to set up the AWS CLI environment. (if you don’t already have one), Check here to know more about AWS Introduction and the Free Tier account sign up step by step. Depending on your operating system and environment, there are different ways to install the AWS CLI: an MSI installer, a bundled installer, or pip. In this article, I am going to show you step by step AWS CLI installation and Configuration on Linux (CentOS/ Redhat).
AWS Command Line Interface: The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts. –source AWS Doc.
AWS CLI provides a unified Command Line Interface to manage the Amazon Web Services. And its works based on Python. AWS CLI is the easiest tool to manage all your Amazon Web Services.
The primary distribution method for the AWS CLI on Linux, Windows, and macOS is “pip”, a package manager for Python that provides an easy way to install, upgrade, and remove Python packages and their dependencies.
Suggestible Read: How to Create Amazon EC2 Instance | Step by Step guide | WebGUI
AWS CLI Installation: AWS CLI installation is the easiest way to install using with PIP.
Here I am going to configure AWS CLI on Linux system. So you will get PIP Package on EPEL repository. Configure Extra Packages for Enterprise Linux (EPEL) then run the below command to install PIP.
Note: The AWS CLI makes API calls to services over HTTPS. Outbound connections on TCP port 443 must be enabled in order to perform calls.
Pre-Requisites for AWS CLI Configuration:
- Python 2 version 2.6.5+ or Python 3 version 3.3+
- Windows, Linux, macOS, or Unix
- Internet Access to able to connect AWS
- PIP (Python Package Index)
To Install Python-pip follow the below command:
First Install and Configure EPEL Repository.
|[[email protected] ~]# yum install epel-release –y|
Now Install Python-pip with below command.
|[[email protected] ~]# yum install python-pip –y|
Note: Python-pip package is available from EPEL Repository.
After installation of PIP, just execute the below command to install AWSCLI along with their all dependency packages.
Installation of AWS CLI on CentOS/RHEL 7
After installing the python and pip, now run the below command to Install AWS-CLI along with dependencies
|[[email protected] ~]# pip install awscli|
If you have the aws-cli installed and want to upgrade to the latest version you can run:
|[[email protected] ~]# pip install –upgrade awscli|
Verify that the AWS CLI version and the manual page.
|[[email protected] ~]# aws –version|
|aws-cli/1.11.66 Python/2.7.5 Linux/3.10.0-327.el7.x86_64 botocore/1.5.29|
AWS CLI Help page
|[[email protected] ~]# aws help|
Creating Access key ID and Secret access key
Before configuring the AWS CLI, you need to get your access key ID and secret access key which are used to sign programmatic requests that you make to AWS. If you don’t have access keys, you can create them by using the AWS Management Console. AWS recommends that you use IAM User access keys instead of AWS root account access keys. IAM lets you securely control access to AWS services and resources in your AWS account.
Note: IAM Roles is the best way to avoid the key-based authentication in your aws environment.
To sign in for an AWS account just open https://aws.amazon.com/, and then go to My Security Credentials from your account name. Follow the below instructions to create your first Access Keys ID and Secret Access Key.
Choose the Security Credentials tab and then choose to Create Access Key
To see your access key, choose Show User Security Credentials. Your credentials will look something like this:
If you don’t have any, then create a New Access key and Download it.
Access keys consist of an access key ID and secret access key, which are used to sign programmatic requests that you make to AWS. If you don’t have access keys, you can create them by using the AWS Management Console. We recommend that you use IAM access keys instead of AWS root account access keys. IAM lets you securely control access to AWS services and resources in your AWS account.
Configuring AWS CLI :
You can configure it using “aws configure” command and this will ask you to provide the AWS Access Key ID and AWS Secret Access Key, Default Region name, Default output format. You need to provide that information as shown below
Here are my example details:
Note: Don’t try to use the below keys, it’s already deleted before this guide published.
|[[email protected] ~]# aws configure|
AWS Access Key ID: AKIAJKK7VB6TXPTOHNTA
AWS Secret Access Key : t5DSysqgCfee26s+nmUa9wu12kMnTWBsdk2C/LeR
Default region name [us-west-2]:
Default output format [None]:
[[email protected] ~]#
–region – AWS region to call your requests.
–output – The Command output format
— AWS_ACCESS_KEY_ID – AWS access key.
— AWS_SECRET_ACCESS_KEY – AWS secret key. Access and secret key variables override credentials stored in credential and config files.
Once the configuration completes, It will create .aws folder in user’s home directory along with config file and credentials like below.
Verifying AWS CLI Configuration:
The below command will list out your instances from the given region.
|[[email protected] ~]# aws ec2 describe-instances –output table –region us-west-2|
Default output format can be either json, text, or table. If you don’t specify an output format, json will be used.
Summary: AWS CLI is the easiest very to manage your AWS resources, and I hope this will like Unix/Linux Admins most. If you have any queries/suggestions please command on below, I will try to get back with my answers.