How to install aws cli in Ubuntu 18.04 &16.04 LTS By manikanta
Today my question is why we should use aws cli in our environment. Let’s discuss I think you know very well our IT sector is moving toward automation and we are performing our 90% task with the help of automation tools like Jenkins, Ansible, Bit-bucket, Bamboo, etc. etc. similarly aws cli is automation tool of AWS that provides help us to automate our daily basis task. In simple language you can use aws cli to create scripts for automating your Amazon Web Services.
In this article we will discuss how to install aws cli in Ubuntu 18.04&16.04 LTS.
There are mainly two way to install aws cli in Ubuntu. Let’s discuss one by one.
- From official repository of Ubuntu
- Using python pip
Method 1: Using apt repository to install aws cli in Ubuntu.
First of all we will install from official repository of Ubuntu. Check the Ubuntu version first and then update official repository of Ubuntu.
1
|
cat /etc/lsb-release
|

1
|
apt-get update
|
Now we are going to install aws cli, kindly run below command and follow the step.
1
|
apt-get install awscli
|

1
|
aws --version
|

Method 2: Installing with Python Pip.
We have successfully installed aws cli but when I have checked this is showing old version let’s upgrade to new version with the help of pip. Use the curl command to download the installation scripts.
1
|
curl -O https://bootstrap.pypa.io/get-pip.py
|

When our scripts will download then we will execute this script with the help of python follow below step.
1
|
python3 get-pip.py --user
|

when you have installed pip than you have to add it’s variable by default it’s not installed.
1
2
|
export PATH=~/.local/bin:$PATH
source ~/.profile
|
Now install aws cli from pip.
1
|
pip3 install awscli --upgrade --user
|

1
|
aws --version
|

Now You have successfully upgraded your aws old version to new version but still you didn’t add your AWS access key and security key file from aws gui console to aws cli. Without adding access key and security key you can not access your aws cli. Let’s do it.
Configuring AWS CLI
1
|
aws configure
|

Now check your access key and security key has been successfully configured or not.
1
2
|
cat .aws/config
cat .aws/credentials
|

How to Verify AWS CLI configured properly?
Up to this step we have successfully installed aws cli let’s check it working fine or not. For this purpose you have to executing any of the below commands and see it’s working fine without any error.
1
|
aws help
|
The following command displays the available Amazon Elastic Compute Cloud (Amazon EC2) specific commands.
1
|
aws s3 ls
|
The above command will get the listing of all s3 buckets in your account.
1
|
aws ec2 describe-instances
|
That should list all the instances in your account.
1
|
aws ec2 stop-instances --instance-ids i-da2345532
|
If want to stop your instance change your instance id in above command and then hit enter this command will stop your instance no need to stop from aws console.
Conclusion
In this tutorial we have discussed how to install aws cli in Ubuntu. If you want to automate your aws infra then defiantly you should know about aws cli because this is the best way to automate your aws daily basis task by making a simple script.Only run that script your task will automatically done.
Comments
Post a Comment