This comprehensive Linux guide expects that you run the following commands as root user but if you decide to run the commands as a different user then ensure that the user has sudo access and that you precede each of the privileged commands with sudo

The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

The AWS CLI introduces a new set of simple file commands for efficient file transfers to and from Amazon S3.

This tutorial will guide you about how to configure AWS CLI on your system. To do that, you first need to get your AWS Account & Credentials.

Installing AWS CLI

To install AWS CLI on your system, first you need to have Python 2.6.5+ or Python 3.3+ installed on your system. If you have that installed on your system, you can follow the instructions below to install the AWS CLI.

Installing AWS CLI Using pip

To install AWS CLI using pip command, you first need to be sure that the pip is installed on your system.

Run the following command to install AWS CLI:

root@codesposts:~$ pip install awscli --upgrade --user

If you are having python 3.x and pip3 installed on your system, then run the following command:

root@codesposts:~$ pip3 install awscli --upgrade --user

You can verify the installation by running the following command:

root@codesposts:~$ python -m awscli --version

OR

root@codesposts:~$ python3 -m awscli --version

Installing AWS CLI Using Package Manager

First, update your package repository using the following command:

root@codesposts:~$ apt-get update

Then run the following command to install AWS CLI:

root@codesposts:~$ apt-get install awscli

You can verify the installation by running the following command:

root@codesposts:~$ aws --version

Installing AWS CLI Using Package Files

To install AWS on your linux/macOS/unix system, first run the following command:

root@codesposts:~$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"

After completing the download, you need to unzip the downloaded file by running the command below:

root@codesposts:~$ unzip awscli-bundle.zip

Then you can run the installation by running the following command:

root@codesposts:~$ ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

Installing On Windows

You can download the Official installer from the links given below. There are 3 types of installers available:

The CLI Setup File will detect the version of the windows you are running and will automatically install the appropriate version on your system.

Simple Configuration Of AWS CLI

If you are configuring AWS CLI for the first time, you can run the following command. This will configure your AWS credentials as your default profile.

root@codesposts:~$ aws configure

AWS Access Key ID [None]: 
AWS Secret Access Key [None]: 
Default region name [None]: 
Default output format [None]: 

[None] Shows that you don’t have any existing value for that variable.
If you leave the output format empty, the default output format will be in json format. The available formats are json, text and table.

Configuring Credentials Files

After the configuration of the AWS, run the following commands to edit the configuration files:

root@codesposts:~$ cat ~/.aws/config

[default]
region = us-east-1
output = text

After that, run the following command:

root@codesposts:~$ cat ~/.aws/credentials

[default]
aws_access_key_id = ********************
aws_secret_access_key = *****************************************

The ~/.aws/config contains the non-credential information like region and output.

The ~/.aws/credentials file contains the credential information.

Configuring AWS Named Profile

If you want to create a named profile for AWS CLI, you can use the --profile argument with the aws command.

root@codesposts:~$ aws configure --profile profile-name

AWS Access Key ID [None]: ********************
AWS Secret Access Key [None]: *****************************************
Default region name [None]: eu-west-1
Default output format [None]: json

Modifying Existing Info

If you want to change the existing credentials or information of the AWS account, you can run the command like below, the existing credentials will be shown in [] brackets.

root@codesposts:~$ aws configure

AWS Access Key ID [****************1234]: 
AWS Secret Access Key [****************1234]: 
Default region name [eu-west-1]: 
Default output format [json]: table

You can re-enter the new credentials here.

Displaying Configuration Data

To display the AWS CLI configuration data for the default profile, you can run the following command:

root@codesposts:~$ aws configure list

      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************1234 shared-credentials-file    
secret_key     ****************1234 shared-credentials-file    
    region                eu-west-1      config-file    ~/.aws/config

Switching Between Different Profiles

If you run any AWS command, it will be executed for the default profile. But if you want to run a command for a specific profile, you can use the --profile argument with the aws command.

For example, If you want to display the EBS volumes for a specific profile, you can run the command like below:

root@codesposts:~$ aws ec2 describe-volumes --profile profile-name

Displaying Specific Parameter Value

You can display just one specific parameter value of the configuration of the profile by using the the get argument with the aws command.

root@codesposts:~$ aws configure get varname [--profile profile-name]

Displaying Specific Parameter Value

You can set specific parameter value of the configuration of the profile by using the the set argument with the aws command.

root@codesposts:~$ aws configure set output text