Setup and Configure AWS CLI on Linux Ubuntu
Amazon Web Service is one of the biggest Cloud Service that provide a lots of various service such us Compute (EC2), Storage (S3), Datavase (RDS) and much more. AWS offers flexibility on running our application. AWS can be managed both from graphical user interface (GUI) (or I call it AWS console) and command line interface (CLI). When the first time using AWS, we should register our account from the AWS web console here. After registering our account, by default we will have access to manage our AWS service from web console (GUI) as a root user.
In the other hand, we can also manage our AWS service by using command line interface (CLI) with access key. Now, let’s see how to done with it.
Create AWS User
First, we need to create another root user and setup its access key. Go to IAM service on AWS web console and choose Users menu then Create user.
You can specify your user details as you want. For example, here my user details.
Make sure to create your password as the required character or you can autogenerate the password for your user.
Next, we will set the user permission as the Administrator user.
You can then now review your user details that will be created and if match, then Create user.
Now, after user is created then we need to create the access key that we will use to manage the AWS service using command line interface. Just go ahead for Create access key.
And for the use case, choose the Command Line Interface (CLI) and make sure to check the box for confirmation.
You can create the optional tag for your access key first or directly create the access key.
After creating your access key, then you can copy both Access key and Secret access key (something like user and password) or you can directly download it as .csv file.
Install and Configure AWS CLI SDK
After creating our user and its access key, now we will install the AWS CLI SDK on our computer. So simply, the AWS CLI is a tool that we can use to interact with our AWS Service by command line. The AWS CLI can be installed in Linux, Windows and MacOS. Please refer to this refrence for more detail. You can choose your method base on what OS that you are using. Because I’am using Linux OS, so I will follow it. Just run below command if you’re using Linux
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
After that, we can verify it by execute aws --version
to see that version is installed.
Now, we will configure that AWS CLI credential on our computers.
Basically, the credential will be saved for each user profile. We can create our custom profile or it will be default
profile if we not specify the profile. For now, I will use the default profile name. You an execute below command to configure it.
aws configure
Then, you need to input your downloaded credential lastly. And for region name, you can specify base on your own region.
The credential will be saved into ~/.aws/ directory and you will have two files which are credentials and config file.
Or actually you can directly create the credentials and config file in ~/.aws/ directory and fill your credential and config manually.
Testing
Now, we can test the user access that we have configured. For example, we want to list the EC2 instances and list the S3 bucket.
aws ec2 describe-instances
aws s3 ls
Make sure that the command can be successfully executed and you don’t get the permission denied error or something.
Thanks for reading. Gooo ahead!!