How to Install AWS Cli on Ubuntu and Configure AWS Cli?

Introduction

AWS Cli is a tool which is used to access and control multiple AWS services from a command line. It is available for Windows, Linux, Mac and also as a Docker image. 

You can download and install the AWS client, configure it once and use it at any point of time you want to access any AWS service. No configuration or login is necessary for each time you want to access your AWS service. AWSCli V2 is the latest version of the AWS client.

In this tutorial, you’ll download, install AWS cli on Ubuntu and configure AWS Cli on Ubuntu.

Prerequisites

  • AWS Account
  • Security Credentials(Access key & Secret access Key) for your account.

Step 1 – Installing AWS Cli on Ubuntu

In this step, you’ll install AWS Cli on Ubuntu. First you’ll update all the packages installed in your Ubuntu Installation. it can be installed using the sudo apt update and sudo apt -y upgrade command as below.

sudo apt update
sudo apt -y upgrade

The -y flag means that you agreeing to the terms of the all items that is updated. However, you may need to agree to the prompts during the update depending on the version of Linux you use.

Your packages are up-to-date.

Now you’ll install AWS-CLI using the curl command.

curl tool is used to copy data from a server to another server.

Execute the below command to copy the AWS client package from Amazon server to your server.

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

The package is not downloaded to your local server as a zip file.

You need to unzip the file before accessing the files from it. To unzip a zip file, unzip package must be installed in your server.

Use the below command to install the unzip package.

sudo apt install unzip

Now the unzip package is installed. Use the below command to unzip the awscliv2 zip package.

unzip awscliv2.zip

Now its unzipped into your current directory.

Execute the install file available in the /aws/ directory to install the aws client.

sudo ./aws/install

AWSCLi V2 is installed in the location /usr/local/aws-cli and a symbolic link is created to /usr/local/bin. Hence you need not to add the installation location to the Path variable.

Now you’ll check the version of the AWS Client version installed using the below command.

aws --version

This will display the currently installed version of the AWS Client.

aws-cli/2.1.7 Python/3.7.3 Linux/5.4.0-1029-aws exe/x86_64.ubuntu.20 prompt/off

AWS Cli is installed succesfully. Now you’ll start configuring AWS cli to manage and access your aws services.

Step 2 – Creating Access Keys in AWS Console

In this step, you’ll configure the AWS Cli using the access key id and the secret access key

Access key ID and secret access key are used to call aws pro-grammatically via AWS-Cli, powershell tools, or direct AWS-API calls.

To create a Access key ID and secret access key, head over to the My security credentials options as shown below.

Click New Access Key option.

You’ll be seeing a message box which has the information about your access key id and the secret access key. You can directly download the access key file to your local computer by Using Download Key File option. It will be downloaded as a csv file.

You can also click Show Access key option to display the access key directly in the window. Once shown, you can copy the key information manually and store in your secure notes.

Either download a file or copy the information to your secure notes. You’ll not be able to view the key information once again. Also creating a key from the root user key is providing unrestricted access to your entire AWS account. Hence be cautious or create a key with the new IAM role.

You have the key information for your aws account. Now you’ll use this information and configure the AWS Cli.

Step 3 – Configuring AWS CLI on Ubuntu

In this step, you’ll configure the AWS cli with the Acess Key ID and Secret Access Key which you have generated in step 2.

aws command is used to access the aws services. Configure parameter with the AWS command allows you to configure the aws client to connect to your aws account.

Use the below command to start the configuration.

 aws configure

Press Enter. You’ll be asked to enter the AWS Access key id. Enter the value you have copied.

 AWS Access Key ID [None]: AKIAXXXXXXXXXXXXXXXXQ 

Press Enter. You’ll be asked to enter the AWS Secret Access key for your Access Key ID. Enter the value you have copied.

 AWS Secret Access Key [None]: JNf0pt2XXXXXXXXXXiXXXMXXXouIXXXXCW2u6R 

Press Enter. You’ll be asked to enter the Default region. Enter your desired default region.

 Default region name [None]: asia 

Press Enter. You’ll be asked to enter the Default output format. Enter your desired default output format. Here you’ll use text as default. Other available output formats are json, yaml, yaml-stream, table.

Default output format [None]: text   

Press Enter. AWS client configuration is successful. Now you’ll verify if the configuration is correctly done.

Step 4 – Checking AWS Cli Configuration

In this step, you’ll verify if the AWS Client is correctly configured and able to access your AWS account.

For this verification, you’ll use the iam get-user command. If everything is configured properly, then you’ll be seeing your user information in the output screen.

Use the below command to get the configured user information.

aws iam get-user

You’ll see the information as given below. The highlighted word shows the configured user name.

 USER    arn:aws:iam::322666080840:root  2020-11-01T10:03:04+00:00       2020-12-04T02:37:36+00:00 322666080840 

To know more about all the commands available in the AWS client, you can use the below command

AWS help

To know more about the service specific commands such as EC2, you can use the below command.

aws ec2 help  

You can replace any service name in the highlighted place to know about that specific service help.

Conclusion

You’ve successfully installed, configured and tested AWSCliV2 on Ubuntu 20.04.

In this tutorial, you’ve learnt how to install aws cli on ubuntu, configure aws cli on ubuntu and tested it.

What Next?

<Watch this space for more updates on Blog>

FAQ

How to install AWS CLI on Linux?

You can use the CURL command to download the AWSCli setup package, unzip the package and install using the command ./aws/install

How to use AWS CLI Linux?

You can use the AWS cli in linux using the $ AWS <commandname>. Just ensure aws cli is installed and configured before using the AWS command.

How do you check AWS CLI is installed?

You can check if AWS Cli is installed by using the command $ AWS –version . If it is installed, it will display the currently installed version details. If not, you’ll see an error.

What is CLI AWS?

AWS Cli is a client tool used to connect and manage your aws services from your local computer.

Leave a Comment

Share via
Copy link
Powered by Social Snap