Home » Install AWS CLI Ubuntu

Install AWS CLI Ubuntu

by Online Tutorials Library

Install AWS CLI Ubuntu

AWS CLI is short for AWS Command Line Interface. It is a combined tool for managing the services of our AWS. We can manage more than one service of AWS using the command line and also automate them using scripts with only a single tool for downloading and configuring.

The AWS CLI version 2 facilitates various new features including developed installers and new options of configuration such as several interactive features and AWS Single Sign-On (SSO).

This command-line interface enables us to interact with the services of AWS with the help of the commands in our command-line shell. The AWS CLI enables us to begin running commands that operate functionality which is equivalent to that given by the AWS Management Console (browser-based) using the command prompt in our terminal program with minimal configuration:

  • Linux shells: These shells are using common programs of the shell such as tcsh, zsh, and bash to execute commands in macOS or Linux.
  • Windows command line: It runs commands in PowerShell or Windows command prompt on Windows.
  • Remotely: It runs commands on Amazon EC2 (Amazon Elastic Compute Cloud) instances using the program of a remote terminal such as AWS Systems Manager, or SSH or PuTTY.

Every IaaS (Infrastructure as a Service) AWS access, administration, and management function within the AWS Management Console is present inside the AWS CLI and AWS API. New services and features of the AWS IaaS facilitate complete functionality of AWS Management Console through the CLI and API in 180 days of launch or at launch.

The AWS CLI facilitates direct access to the public AWS services APIs. We can explore the capabilities of a service using the AWS CLI and improve the scripts of the shell for managing our resources. Several API-equivalent commands and many services of AWS offer customizations for the AWS CLI in inclusion to the low level. Customizations can add high-level commands with a complex API using a service.

aws-shell (Preview of Developer)

aws-shell can be described as a program of the command-line shell that offers productivity and convenience features to support both advanced and new users of AWS CLI. Some of the important aspects are mentioned below:

Install AWS CLI Ubuntu

  1. Auto-completion for:
    Resource identifiers Amazon SNS topic names (e.g., Amazon SNS topic names, Amazon SQS queue URLs, Amazon EC2 instance IDs)
    Options (e.g., –queue-url, –instance-ids)
    Commands (e.g., create-queue, describe-instances, ec2)
  2. OS shell commands execution:
    Use common commands of OS such as pipe, cp, ls, and cat outputs and inputs without living the shell
  3. In-line documentation (Dynamic)
    Documentation for options and commands are shown as we type
  4. Export executed commands for a text editor

Versions of the AWS CLI

The AWS CLI exists in two versions and the details in this guide are uses in both of the versions.

  1. Version 2.x: It is generally available and the current version of AWS CLI. It is intended to use in the environments of production.
  2. Version 1.x: the old version of the AWS CLI that exists for backwards capability.

About the Amazon Web Services

The AWS (or Amazon Web Services) is a set of services of digital infrastructure that developers could leverage when integrating their applications. These services include database, storage, computing, and synchronization of applications (queuing and messaging). AWS applies a service model, i.e., ‘pay-as-you-go’.

We are charged just for the services that we or our applications use. AWS facilitates the tier of free usage for making AWS more convenient as an environment for experimentation and prototyping. We don’t have to pay for the services as they are free under a certain usage on this tier.

Synopsis of AWS CLI

  • We can use the help of the AWS command for details on a particular command.
  • We can use the help topics of AWS for viewing the list of existed help topics.
  • The synopsis for all commands displays their uses and their parameters.
  • Optional parameters are displayed in square brackets.

Options

  • Turning on debug logging

Override the default URL of the command with the provided URL

  • The AWS CLI by default uses SSL if communicating with the services of AWS. The AWS CLI would verify the certificates of SSL for every SSL connection. This option will override the default nature of verifying the certificates of SSL.
  • Disabling automatic pagination.
  • The formatting way for command result.
    • text
    • table
    • json
  • The query of a JMESPath for applying in filtering the returned data.
  • Use a particular profile from our credential file.
  • The region for using. It overrides the settings of env/config.
  • Show the version of the tool.
  • Turn off/on the output of color.
    • auto
    • off
    • on
  • Don’t sign requests. Credentials would not be loaded when this argument is given.
  • The bundle of the CA certificate for using if verifying the certificates of SSL. It overrides the settings of env/config.
  • The maximum read time of the socket is in seconds. The read of a socket would not timeout and would be blocking when the value is fixed to 0. 60 seconds is the default value.
  • The maximum connection time of the socket is in seconds. The connection of a socket would not timeout and would be blocking when the value is fixed to 0. 60 seconds is the default value.

New features of AWS CLI v2

The AWS CLI v2 provides various new features such as integrated installers, new options of configuration like Single Sign-On (SSO), and several other interactive features.

Some of the important features are listed and discussed below:

Install AWS CLI Ubuntu

1. New mechanisms of installation

The AWS CLI version 2 gives pre-built binaries for macOS, Linux, and Windows. We no longer require to have Python installed to apply the AWS CLI. We do not need to worry about compatible versions of Python, conflicting packages of Python, or virtual environments. We give an MSI installer on Windows and a .pkg Installer on macOS.

2. Mechanisms of AWS configuration

AWS CLI v2 introduces various new mechanisms to configure credentials. They have added a new command, i.e., “aws configure import” for importing credentials with the .csv files produced within the AWS Console.

Also, they have included support for a new command, i.e., “aws configure wizard” that facilitates a guided walkthrough to configure credentials of AWS. This version supports using and configuring credentials from AWS SSO with a new command, i.e., “aws configure sso” in inclusion to these commands. It will ask us a question series for helping us configure the AWS CLI.

3. Interactive features of the AWS CLI v2

One of the biggest themes for this version was adding more interactive aspects to support customers. The AWS CLI is applied for both interactive usage and automated scripting tasks as well, and we wished for including aspects that support users when they are interactively executing the commands of CLI in a terminal. A few new interactive aspects include wizards, server-side auto-completion, and the command, i.e., –cli-auto-prompt.

a. Server-side auto-completion

We could apply the command aws_completer for the command’s tab completion and the names of the parameter in AWS CLI v1.

They have upgraded the auto-completer for completing the resource names of the server-side in AWS CLI v2.

b. Auto-prompt

The auto-completion feature supports us to more efficiently input the parameters of CLI, but sometimes we are not sure that which parameters we wish to offer.

The new feature, i.e., –cli-auto-prompt can support us. We can include this parameter in all built-in commands of CLI and the CLI will instruct us by entering the values of the parameter.

  1. It will first ask us for every required parameter.
  2. We will be represented with the optional parameter list once we have entered every required parameter. Also, the initial statement of the documentation is included for all parameters.
  3. We can choose ‘Parameter input finished’ once we have entered every parameter we wish, and we will have an option to either print the command for us or the AWS CLI conjure the command.

c. Wizards

In AWS CLI v2, the feature of new wizards guides us from managing several resources of AWS. They are an abstraction of a higher level as compared to –cli-auto-prompt and combine more than one call of AWS API for creating, updating, or deleting the resources of AWS.

They are the same as the workflows of getting started inside the AWS console. They have added wizards to the starting set of the services of AWS. We can execute <service-name> wizard <wizard-name> for accessing these wizards. Also, wizards support querying for available resources when asking us for data. They have added wizards for the lambda, iam, dynamodb, and configure commands.

Installing, updating, and uninstalling the AWS CLI version 1 in Linux Ubuntu

We can install the AWS CLI (AWS command-line interface) version1 and its dependencies in most of the distributions of Linux with the help of the bundled installer or the pip package manager.

However, the package awscli is present in repositories for several package managers like yum and apt. These are not supported, managed, or produced by AWS. We suggest that we install this version using only the distribution points of the official AWS.

Prerequisites

We must have the 2.7 version of Python 2 or later, or the 3.6 version of Python 3 or later installed in our system.

Installing and uninstalling the AWS CLI version 1 in Ubuntu with the bundled installer

On macOS on Linux, we can apply the bundled installer for installing AWS CLI version 1. The bundled installer contains every dependency and could be used offline.

Important: The bundled installer does not help to install paths that include spaces.

Installing version 1 of AWS CLI with the bundled installer using sudo

The below steps enable us to install version 1 of AWS CLI from the command-line on all builds of macOS or Linux. The following is the installation commands summary which is mentioned below that we can copy and paste to execute as one command set. We can use the below command block for the latest AWS CLI version:

We can attach a hyphen and the number of the version to the filename for a specific AWS CLI version. The filename for the 1.16.312 version will be awscli-bundle-1.16.312.zip appearing in the below command:

Explanation of the above commands in detail:

We can follow the steps using the command line for installing the AWS CLI version 1 with the help of the bundled installer.

1. Download the AWS CLI version 1 bundled installer with the help of one of the below methods.

Download with the command, i.e., curl.

We can use the below command block for the latest AWS CLI version:

Install AWS CLI Ubuntu

We can use the below command block for a specific AWS CLI version:

2. Extract these files from our package. If we do not have to unzip for extracting these files, we can use the built-in package manager of our Linux distribution for installing it.

Install AWS CLI Ubuntu

3. Now, we can install AWS CLI using the command which is mentioned below:

Install AWS CLI Ubuntu

4. We need to verify that the AWS CLI is correctly installed.

Install AWS CLI Ubuntu

Installing version 1 of AWS CLI with the bundled installer without using sudo

If we do not have the permissions of sudo or wish to install this version only for the latest user, then we can use a changed version of the old commands. The initial two commands will be the same.

We can use the below command block for the latest AWS CLI version:

We can attach a hyphen and the number of the version to the filename for a specific AWS CLI version. The filename for the 1.16.312 version will be awscli-bundle-1.16.312.zip appearing in the below command:

For installing version 1 of AWS CLI for the latest user

1. Download version 1 of AWS CLI bundled installer with the help of one of the below methods.

Download with the command, i.e., curl.

We can use the below command block for the latest AWS CLI version:

We can use the below command block for a specific AWS CLI version:

2. Extract these files from our package with the help of the unzip command. If we do not have the unzip command for extracting these files, we can use the built-in package manager of our Linux distribution for installing it.

3. Execute the install program. To do this, the installer will install the AWS CLI in the /usr/local/aws directory and makes the aws symlink in a directory, i.e., /usr/local/bin. The command will use the parameter -b for specifying the directory in which the installer will place the symlink aws file. We must have all write permissions to the described folder.

It will install the AWS CLI in the ~/.local/lib/aws default location and makes a symbolic link (or symlink) in the ~/bin/aws directory. Ensure that ~/bin is inside the environment variable, i.e., PATH for the symbolic link to work.

4. ((check if $PATH variable includes ~/bin (if it does not the result will be empty))

5. (If necessary, include ~/bin to the $PATH variable)

6. Make sure the directory that version 1 AWS CLI is a part of our $PATH variable.

a. Find the profile script of our shell in our user folder. If we are not sure which shall we have, execute echo $ SHELL.

Install AWS CLI Ubuntu

Tcsh: .login, .cshrc, or .tcshrc

Zsh: .zshrc

Bash: .bash_login, .profile, or .bash_profile

b. Include an export command at the completion of our profile script that is the same as the below example:

The above command will insert the ~./local/bin path in the starting of the available PATH variable in this example.

c. Reload the profile in our current session for putting those modifications into effect.

d. Verify that the installed AWS CLI is correct.

Install AWS CLI Ubuntu

Uninstall version 1 AWS CLI bundle installer

If we installed version1 AWS CLI with the help of the bundled installer, we need to follow some instructions. The bundle installer does not put anything external to the installation directory exclude the optional symbolic link. Hence, uninstalling is as easy as removing those two items.

Install AWS CLI Ubuntu


Next TopicInstall NVM Ubuntu

You may also like