If you are into servers or DevOps, AWS is one of the most crucial things to have in your tech stack.
To manage, configure and control multiple AWS services, you can use the AWS CLI tool from Amazon.
It is available in Ubuntu's Universe repository, although it may not be the latest version.
You can install it using this command:
sudo apt install awscli
Once done, you can check the installed version using:
And as you can see, I got AWS CLI version 1.22.34.
But if you want the latest version possible, it needs to be installed manually and in this tutorial, I will show you how to do it.
How to install the latest version of AWS CLI in Ubuntu
To install the latest version of AWS CLI in Ubuntu, first, you'd have to install prerequisites using the following:
sudo apt install curl unzip
First, download the zip file using the curl command as shown:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
Now, use the unzip command to extract files:
And finally, use the following command to install the AWS CLI:
Once done, you can check the installed version using the following:
As you can see, I got AWS CLI version 2.11.24 which is far ahead of what I got using the apt.
How to configure AWS CLI in Ubuntu
First, let's have a look at how you can access your Access key and secret keys.
First, log in to your console using the browser, and click on your profile. Here, it will show the option
Now, find the option for
Aceess keys here it will show keys if you have generated them previously.
And if you haven't, then, you can generate keys by clicking on
Create access key:
It will create the keys for you.
Now, you have keys, so let's start the configuration.
To start the configuration, all you have to do is append the
configure flag to the aws command:
And enter the details:
That's it! The AWS is configured.
Once you are done with the configuration, it will create two directories inside
$HOME/.aws and you can check out its contents using the ls command:
But what are those files? Let me explain:
config: Contains all the information related to the configuration you made such as default region and type of default output.
credentials: Contains access key and secret key as plain text.
Now, let's put the configuration to the test.
You can use the following command and it will print information about the instances you've created:
aws ec2 describe-instances
Working as expected! Enjoy controlling your AWS services from Ubuntu.