how to install and configure aws cli on linux ?

AWS Command Line Interface (CLI). Depending on your operating system ways are different for installation. I will show you installation of AWS CLI on Ubuntu and CentOS Linux OS.

Install AWS Command Line Interface ( CLI)

Install AWS CLI in Ubuntu Linux

Pip is recommended method of installing AWS CLI on Linux which is python based tool helps in install, upgrade, and remove Python packages.

– Install python-pip package using apt-get

[root@linuxforfreshers~] apt-get install python-pip

Install AWS CLI using pip command

[root@linuxforfreshers~] pip install awscli

You can configure it using “aws configure” command.

While configuring, it will ask you for the several information like AWS Access Key ID, AWS Secret Access Key, Default region name, Default output format. You need to provide that information. In my case below is the Access Key and Secret Access Key.

AWS Access Key = AKIAJRSF3SHFXWALVL2A

AWS Secret Access Key = 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

Let’s configure it using command.

[root@linuxforfreshers~] aws configure

AWS Access Key ID [None]: AKIAJRSF3SHFXWALVL2A

AWS Secret Access Key [None]: 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

Default region name [None]: us-east-1

Default output format [None]:

Once configuration complete, It will create .aws folder in user’s home directory. Below is the content of .aws directory.

[root@linuxforfreshers~] ls .aws/

[root@linuxforfreshers~] cat .aws/config

[root@linuxforfreshers~] cat .aws/credentials

aws_access_key_id = AKIAJRSF3SHFXWALVL2A

aws_secret_access_key = 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

– Now Test if AWS CLI is installed correctly or not.

[root@linuxforfreshers~] aws help

If you are given wrong access_key u will get following error.

An error occurred (InvalidAccessKeyId) when calling the ListBuckets operation: The AWS Access Key Id you provided does not exist in our records.

– Check Version of AWS CLI.

[root@linuxforfreshers]aws –version

aws-cli/1.11.129 Python/2.7.6 Linux/4.4.0-59-generic botocore/1.5.92

Install AWS CLI in CentOS Linux

– Check if python is installed in your system or not. If not install it using below command.

[root@linuxforfreshers~]# yum -y install python

Download the installation script.

[root@linuxforfreshers~]# curl -O https://bootstrap.pypa.io/get-pip.py

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

100 1388k 100 1388k 0 0 205k 0 0:00:06 0:00:06 –:–:– 265k

[root@linuxforfreshers~]#

Run the script with Python.

[root@linuxforfreshers~]# python get-pip.py

Downloading pip-7.0.3-py2.py3-none-any.whl (1.1MB)

100% |████████████████████████████████| 1.1MB 155kB/s

Downloading wheel-0.24.0-py2.py3-none-any.whl (63kB)

100% |████████████████████████████████| 65kB 252kB/s

Collecting argparse (from wheel)

Downloading argparse-1.3.0-py2.py3-none-any.whl

Installing collected packages: pip, argparse, wheel

Successfully installed argparse-1.3.0 pip-7.0.3 wheel-0.24.0

[root@linuxforfreshers~]#

– Now install AWS command line using pip.

[root@linuxforfreshers~]# pip install awscli

– Let’s configure AWS CLI.

[root@linuxforfreshers~] aws configure

AWS Access Key ID [None]: AKIAJRSF3SHFXWALVL2A

AWS Secret Access Key [None]: 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

Default region name [None]: us-east-1

Default output format [None]:

– Verify either file and folder is created.

[root@linuxforfreshers~] ls .aws/

[root@linuxforfreshers~] cat .aws/config

[root@linuxforfreshers~] cat .aws/credentials

aws_access_key_id = AKIAJRSF3SHFXWALVL2A

aws_secret_access_key = HZiGF4VQKRzblpk8WmaQnwioR0qFhUO25phWptEi

Installation is complete now and you can start using aws cli.

 

Source

Leave a Reply

Your email address will not be published. Required fields are marked *

WP2Social Auto Publish Powered By : XYZScripts.com