In the next article we are going to take a look at the AWS Command Line Interface. The AWS or Amazon Web Service command line interface is a command line tool for manage our Amazon web services.
AWS CLI provides direct access to the Amazon Web Services public API. As it is a command line tool, it can also be used to create scripts to automate your Amazon web services. In this article we are going to see two ways to install the AWS CLI tool on our Ubuntu 18.04 LTS.
Installing the AWS CLI on Ubuntu 18.04
With APT
AWS CLI is available in the official Ubuntu 18.04 LTS package repository. Therefore, it is very easy to install it. First we update the package listing cache with the following command in the terminal (Ctrl + Alt + T):
sudo apt-get update
Now we are going to install the AWS CLI using the command:
sudo apt-get install awscli
After this, the program should already be installed on our system. We will can check if AWS CLI is working correctly with the following command:
aws --version
As you can see in the following screenshot, the AWS CLI is working correctly.
With Python PIP
AWS CLI is a Python module. The advantage of installing AWS CLI as a Python module is that always Get an updated version of the AWS CLI. It's easy to update the AWS CLI if it's installed as a Python module. We also won't need root privileges to install the AWS CLI in this way. If we need it, AWS CLI too can be installed in a virtual Python environment.
AWS CLI is available for Python 2.x and Python 3.x. For this example I will use version 3 of Python. As I say, we will need Python PIP to install this program on our Ubuntu. python pip it is not installed by default on Ubuntu 18.04 LTS. But it is easy to install.
Run the following command to install Python PIP:
sudo apt-get install python3-pip
Python PIP should be installed. Now we will be able install AWS CLI using PIP with the following command in the terminal (Ctrl + Alt + T):
pip3 install awscli --upgrade --user
The AWS CLI Python module must be installed and we can check if this is the case by typing:
python3 -m awscli --version
As you can see, the AWS CLI has also successfully installed the latest version using Python.
AWS CLI Basics
I'd like to show you how the AWS CLI works in a practical way, but I haven't verified my AWS account. That is why the data that I will use is obtained from a screenshot that I found in an image search from Google. Each user will have to replace the data shown here with your own.
For this exercise I am using the AWS CLI program from the LTS packaged version of Ubuntu 18.04, not the Python module, but the commands are similar.
When we want to log into the AWS account using the AWS CLI, first we must configure the client with the credentials of our AWS account. To do this, run the following command:
aws configure
If you have used the AWS CLI Python module uses this other:
python -m awscli configure
After this, we will have to type our AWS passkey ID and press Enter. The next thing it will ask us to do is type our AWS secret access key ID and press Enter. A passkey ID and a secret passkey ID can be created from AWS Management Console.
We will also have to type in our default region name. It is something like us-west-2 in this example.
Now we will write our default output format. We can choose between the default value, in which case we will only have to press Enter. Or we can also select the JSON format (JavaScript Object Notation), in which case we'll type json and hit Enter.
Now we can manage our Amazon Web Services using the AWS CLI.
The AWS CLI configuration files they are stored in ~ / .aws / config and ~ / .aws / credentials, as you can see in the following screenshot.
Now when we need to use a different login information, all we will have to do is delete the configuration files mentioned above and run the following command.
rm -v ~/.aws/config ~/.aws/credentials
We will end up executing again the configuration of the program that we have seen before.
Help with the AWS CLI
If anyone needs to know how to get help with this program, AWS has a great guide and quite a bit of documentation that users can use. To consult the help from the terminal we can execute in it:
aws help
If we choose to install the Python module, the help command would be:
python3 -m awscli help
For more information, we can consult the online documentation AWS CLI. In addition we can also download the PDF manual Of this program.