Christmas Special : Upto 40% OFF! + 2 free courses  - SCHEDULE CALL

- AWS Blogs -

What is AWS CLI? How to Install AWS CLI?



Introduction

Amazon Web Services is one of the top market leaders in the era of cloud computing. It helps in the different sectors of technology like gaming, data processing, data warehousing, development, etc. Amazon’s Command Line interface is also the top eye-catcher of the browser console. Using the command line interface, a developer can type a command to designate a profile, region, or output format that is different than default configurations. Today, we’ll discuss the basic terminology associated with AWS CLI, its usage, installation, and a few of the AWS CLI commands. Before you proceed further, consider going for a trending AWS Certification Course.

What is AWS CLI?

The AWS CLI is an open-source tool that enables you to communicate with AWS services using commands in your command-line shell. You may start using the functionality of AWS CLI with theminimal configuration only. The AWS CLI manages your AWS services from a terminal session on your own client and allows you to control and configure multiple AWS services. However, to be a reputed AWS professional much depends on the certification you hold, consider going for industry-recognized Cloud computing certifications.

AWS CLI Terminology

AWS CLI Terminology

  • Linux Shells: Make use of common shell programs such as bash, zsh, and tsch to run commands in Linux, Mac, or Unix
  • Windows Command Line: To run commands on Windows OS, PowerShell or at the command prompt of Windows
  • Remotely: You can run commands on Amazon Elastic Compute Cloud (Amazon EC2) instances through a remote terminal such as PuTTY or SSH, or with AWS System Manager

However, if you are a beginner and want to know how to create your own first amazon ec2 instance and gain in-depth knowledge on What Is AWS Lambda? We recommend you check out these blogs.

Uses of AWS CLI

  • Installation of AWS CLI is quick, simple, and standardized
  • Using command liner saves plenty of your time in many occasions
  • AWS CLI provides you the ability to automate the entire process of controlling and managing AWS services

Installing AWS CLI

  • Using pip
  • Using a virtual environment
  • Using a bundled installer

Using pip

Pip is the primary distribution method for the AWS CLI on Linux, Windows, and macOS. This is said to be a package manager for Python that provides an easy way to install, upgrade, and remove Python packages and their dependencies.

Tip: The AWS Command Line Interface (CLI) is an instrument given by AWS to deal with our AWS administrations. Utilizing this single instrument, you can oversee diverse AWS administrations from the order line.  Check out How to Install the AWS Command Line Interface in various systems. 

Using a virtual environment

If you confront issues while installing the AWS CLI with pip3, you can install the AWS CLI in a virtual environment to isolate the tool and its dependencies. Or you can use a different version of Python than you normally do. For offline or automated installations on Linux, macOS, or Unix, try the bundled installer. The bundled installer incorporates the AWS CLI, its dependencies, and a shell script that installs for you.

On Windows, you can also use the MSI installer. Both of these methods simplify the initial installation. However, the tradeoff is that it's more difficult to upgrade when a new version of the AWS CLI is released.

Note: If you are a beginner looking to excel in your career in AWS. Check out the best High-Paying Cloud Certifications in 2022 that can remarkably boost your career.  You can verify the AWS CLI is installed correctly by running AWS --version command. $ aws --version aws-cli/1.16.116 Python/3.6.8 Linux/4.14.77-81.59-amzn2.x86_64 botocore/1.12.106

Using a bundled installer

You can perform the following steps from the command line to install the AWS CLI using the bundled installer:

  • To install the AWS CLI using the bundled installer, first, download the AWS CLI Bundled Installer: $ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
  • Unzip the package (If you don't have to unzip, use your favorite package manager to install it or an equivalent): $ unzip awscli-bundle.zip
  • Run the install program: $ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

In the context of AWS CLI, AWS Step Functions were one of the most applauded announcements in 2022 which lets you coordinate multiple AWS services into serverless workflows to build and update apps quickly. Check out the AWS Step Functions Concepts with Example to gain complete insight o this domain. 

Installing the current AWS CLI Version

The AWS CLI is updated frequently with the support for new services and commands. If you have already installed pip and a supported version of Python in your system, then you can install the AWS CLI by using the following command. If you have installed Python version 3+, then it is recommended to use the ‘pip3 command’.

$ pip3 install awscli --upgrade --user

The --upgrade option notifies the pip3 to upgrade any requirements that are already installed.

The --user option notifies pip3 to install the program to a subdirectory of your user directory to avoid modifying libraries used by your operating system.

We recommend that you regularly check to see if there is a new version of the AWS CLI and upgrade to it when you can. You can use pip list -o command to check which packages are "outdated':  $ aws --version was-cli/1.16.170 Python/3.7.3 Linux/4.14.123-111.109.amzn2.x86_64 botocore/1.12.160 $ pip3 list -o Package Version Latest Type ---------- -------- -------- ----- awscli 1.16.170 1.16.198 wheel botocore 1.12.160 1.12.188 wheel

Upgrading the Latest Version of the AWS CLI

The AWS CLI is updated frequently to add support for new services and commands. If you want to update the latest version of the AWS CLI, run the install command again.

$ pip3 install awscli --upgrade –user

Uninstalling the AWS CLI

If you need to uninstall the AWS CLI, then use pip uninstall.  $ pip3 uninstall awscli If you don't have Python and pip, use the procedure for your environment.

Installing AWS CLI in Windows

The installation of AWS Command Line Interface (AWS CLI) can be done on Windows by using a standalone installer or pip, which is a package manager for Python. The AWS CLI is supported on Windows XP or later. For the users of Windows, the MSI installation package can be used as a convenient way to install the AWS CLI without installing any other prerequisites. When you find the release of updates, then you have to repeat the installation process to get the latest version of the AWS CLI. To update frequently, it would be better to consider  using pip for easier updates.

To install the AWS CLI using the MSI installer

  • Download the appropriate MSI installer.
    • The download 64-bit version of AWS CLI MSI installer for Windows
    • The download 32-bit version of AWS CLI MSI installer for Windows
    • Download the AWS CLI setup file (includes both the 32-bit and 64-bit MSI installers and will automatically install the correct version)

Note: The MSI installer for the AWS CLI doesn't work with Windows Server 2008 (version 6.0.6002). You have to use pip to to install with this version of Windows Server

  • Run the downloaded MSI installer or the setup file
  • Follow the onscreen instructions.

By default, the CLI installs to C:\Program Files\Amazon\AWSCLI (64-bit version) or C:\Program Files (x86)\Amazon\AWSCLI (32-bit version). To confirm the installation, use the aws --version command at a command prompt (open the Start menu and search for cmd to start a command prompt). C:\> aws --version aws-cli/1.16.116 Python/3.6.8 Windows/10 botocore/1.12.106

Don't attach the prompt symbol (C:\>, shown above) when you type a command. These are attached in program listings to differentiate commands that you type from output returned by the CLI.

If Windows is unable to find the program, you might need to close and reopen the command prompt to refresh the path, or add the installation directory to your PATH environment variable manually.

Updating an MSI Installation

The AWS CLI is updated regularly. If you want to update your previous AWS CLI to the latest version, download and run the MSI installer again, as described previously.

Uninstalling the AWS CLI

To uninstall the AWS CLI from the system, open Control Panel, and then choose Programs and Features. Select AWS Command Line Interface, and then choose Uninstall to launch the uninstaller. Confirm the uninstallation of AWS CLI when you're prompted.

You can also originate the Programs and Features program from the command line with the following command:

C:\> appwiz.cpl

Now, that you have got a taste of this, take this 2-minute free AWS Quiz to check your Cloud computing knowledge and stay updated with the latest updates and innovations in AWS.

Installing the AWS CLI on Linux

The installation of AWS CLI and its dependencies on most Linux distributions  is performed by using pip, a package manager for Python.

The AWS CLI package can be availed through various repositories for other package managers like apt and yum, but you cannot get the latest version unless you get it from pip or use the bundled installer.

Run pip -- version to see if your version of Linux already includes Python and pip. It is recommended to have Python version 3+ installed in your system so that you use the pip3 command.

$ pip3 --version

If you don't already have pip installed, check which version of Python is installed in your system.

$ python --version

or

$ python3 --version

Tip: AWS is a big domain with multiple career options. Yet, for the maximum impact learning, AWS from scratch is important, check out our complete AWS Training & Certification Guide for a rewarding career ahead

Installing the AWS CLI on MAC OS

The paths that show up depending on which method you used to install the AWS CLI.

Typical paths include:

  • Python 3 and pip3 C:\Program Files\Python37\Scripts\
  • Python 3 and pip3 --user option on earlier versions of Windows %USERPROFILE%\AppData \Local\Programs\Python\Python37\Scripts
  • Python 3 and pip3 --user option on Windows 10 %USERPROFILE%\AppData\Roaming\Python \Python37\Scripts
  • MSI installer (64-bit) C:\Program Files\Amazon\AWSCLI\bin
  • MSI installer (32-bit) C:\Program Files (x86)\Amazon\AWSCLI\bin

 Note: Folder names that include version numbers can vary. The examples above reflect the use of Python version 3.7. Replace as needed with the version number you are using.

To modify your PATH variable (Windows)

  1. Press the Windows key and enter environment variables.
  2. Choose Edit environment variables for your account.
  3. Choose PATH, and then choose Edit.
  4. Add the path to the Variable value For example: C:\new\path
  5. Choose OK twice to apply the new settings.
  6. Close any running command prompts and reopen the command prompt window.
  7. The recommended way to install the AWS Command Line Interface (AWS CLI) on macOS is to use the bundled installer. The bundled installer includes all dependencies and you can use it offline.

Important: The bundled installer doesn't support installing on the paths that contain spaces.

Prerequisites

  • Python 2 version 2.6.5+ or Python 3 version 3.3+
  • Check your Python installation :$ python --version

If you have not installed Python in your system or, if you want to install a different version of Python, then follow the procedure  of installation of of the AWS CLI on Linux. Further, if you are looking to garner more information, check out our blog on How to use Amazon EKS and deploy a Kubernetes application to gain better insight. 

How to use AWS CLI?

After walking through the AWS CLI user guide and performing the installation and configuration of the tool, you can begin making calls to your AWS services from the command line. $ aws ec2 describe-instances $ aws ec2 start-instances --instance-ids i-1348636c $ aws sns publish --topic-arn arn:aws:sns:us-east-1:546419318123:OperationsError --message "Script Failure" $ aws sqs receive-message --queue-url https://queue.amazonaws.com/546419318123/Test

You can take help from the command line to view the supported services,

$ aws help

the operations for a service,

$ aws autoscaling help

and the parameters for a service operation.

$ aws autoscaling create-auto-scaling-group help

So, this is how to use AWS CLI. Joining JanBask Training can help you learn more about the platform and get a better understanding of it

AWS CLI Best Practices and Commands

list-commands
[--command-id ]
[--instance-id ]
[--filters ]
[--cli-input-json ]
[--starting-token ]
[--page-size ]
[--max-items ]
[--generate-cli-skeleton ]

Options

--command-id (string)

(Optional) If provided, lists only the specified command.

--instance-id (string)

(Optional) Lists commands issued against this instance ID.

--filters (list)

(Optional) One or more filters. Use filters to return a more specific list of results.

Shorthand Syntax:

key=string,value=string ...

--cli-input-json (string)

You can use the service operation based on the JSON string provided which follows the format provided by --generate-cli-skeleton.

--starting-token (string)

A token to specify where to start paginating. This is the NextToken from a previously truncated response.

--page-size (integer)

The size of each page to get in the AWS service call. There is no effect on the number of items returned in the command's output by using this command. This command can set a smaller page size results in more calls to the AWS service by retrieving fewer items in each call. This can help in the prevention of AWS service calls from timing out.

--max-items (integer)

It is the total number of items to return in the command's output. If the total number of items available is more than the value specified, then the NextToken is provided in the command's output.

--generate-cli-skeleton (string)

It prints a JSON skeleton to standard output without sending an API request. If there is no value or the value input, then it prints a sample input JSON that can be used as an argument for --cli-input-json.

Key -> (string)

It is the user-defined criteria for sending commands that target instances that meet the criteria.

Values -> (list)

It is a user-defined criterion that maps to Key. For example, if you have specified tag: ServerRole, you could specify value: WebServer to run a command on instances that include Amazon EC2 tags of ServerRole, WebServer.

(string)

RequestedDateTime -> (timestamp)

The date and time the command was requested.

Status -> (string)

The status of the command.

StatusDetails -> (string)

A detailed status of the command execution. StatusDetails includes more information than Status because it includes states resulting from error and concurrency control parameters. StatusDetails can show different results than Status.

StatusDetails can be one of the following values:

  • Pending: The command has not been sent to any instances
  • In Progress: The command has been sent to at least one instance but has not reached a final state on all instances
  • Success: The command successfully ran on all invocations. This is a terminal state
  • Delivery Timed Out: The value of MaxErrors or more command invocations shows the status of Delivery Timed Out. This is a terminal state
  • Execution Timed Out: The value of MaxErrors or more command invocations shows a status of Execution Timed Out. This is a terminal state
  • Failed: The value of MaxErrors or more command invocations shows a status of Failed. This is a terminal state
  • Incomplete: The command was attempted on all instances, and one or more invocations does not have a value of Success, but not enough invocations failed for the status to be Failed. This is a terminal state.
  • Canceled: The command was terminated before it was completed. This is a terminal state
  • Rate Exceeded: The number of instances targeted by the command exceeded the account limit for pending invocations. The system has canceled the command before running it on any instance. This is a terminal state.

OutputS3Region -> (string)

(Deprecated) You can no longer specify this parameter as the system ignores it. Instead, the Systems Manager automatically determines the Amazon S3 bucket region.

OutputS3BucketName -> (string)

It is the S3 bucket where the responses to the command executions should be stored. This was requested when issuing the command.

OutputS3KeyPrefix -> (string)

It is the S3 directory path inside the bucket where the responses to the command executions should be stored. This was requested when issuing the command.

MaxConcurrency -> (string)

It is the maximum number of instances that are allowed to run the command at the same time. You can specify the number of instances, such as 10, or a percentage of instances, such as 10%. The default value is 50.

MaxErrors -> (string)

It is the maximum number of errors allowed before the system stops sending the command to additional targets. You can  specify  the number of errors, such as 10, or a percentage or errors, such as 10%. The default value is 0.

MaxErrors -> (string)

It is the maximum number of errors allowed before the system stops sending the command to additional targets. You can specify  the number of errors, such as 10, or a percentage or errors, such as 10%. The default value is 0.

TargetCount -> (integer)

It is the number of targets for the command.

CompletedCount -> (integer)

It is the number of targets for which the command invocation reached a terminal state. Terminal states include the following: Success, Failed, Execution Timed Out, Delivery Timed Out, Canceled, Terminated, or Undeliverable.

ErrorCount -> (integer)

It is the number of targets for which the status is Failed or Execution Timed Out.

DeliveryTimedOutCount -> (integer)

It is the number of targets for which the status is Delivery Timed Out.

ServiceRole -> (string)

It is the IAM service role that Run Command uses to act on your behalf when sending notifications about command status changes.

NotificationConfig -> (structure)

Configurations for sending notifications about command status changes.

NotificationArn -> (string)

It is an Amazon Resource Name (ARN) for an Amazon Simple Notification Service (Amazon SNS) topic. Run Command pushes notifications about command status changes to this topic.

NotificationEvents -> (list)

These are the different events for which you can receive notifications. These events include the following: All (events), InProgress, Success, TimedOut, Cancelled, Failed.

NotificationType -> (string)

The command receives a notification when the status of a command changes. The invocation of this command is to send to multiple instances and receive a notification on a per-instance basis when the status of a command changes.

CloudWatchOutputConfig -> (structure)

The CloudWatch Logs to the information where you want the Systems to send the command output.

CloudWatchLogGroupName -> (string)

The name of the CloudWatch log group where you want to send command output. If you don't specify a group name, Systems Manager automatically creates a log group for you. The log group uses the following naming format: AWS/ssm/SystemsManagerDocumentName.

CloudWatchOutputEnabled -> (boolean)

This command sanctions the Systems to send command output to CloudWatch Logs.

NextToken -> (string)

(Optional) This is the token for the next set of items to return.

Conclusion

AWS is a secure cloud service platform that offers infrastructure services to developers. On the other hand, AWS CLI is like honey for the bee that controls all those services together into a simple command-line interface and eases the task of the developer. So, gear up and give a jumpstart to your AWS professional career by enrolling yourself in a comprehensive AWS Certification Course, today!  If you have any questions for us? Feel free to ask or talk to our counselor; we’ll get back to you! Also, don’t forget to join the professional JanBask AWS Community to get professional guidance and the best career advice

fbicons FaceBook twitterTwitter lingedinLinkedIn pinterest Pinterest emailEmail

     Logo

    JanBask Training

    A dynamic, highly professional, and a global online training course provider committed to propelling the next generation of technology learners with a whole new way of training experience.


  • fb-15
  • twitter-15
  • linkedin-15

Comments

Trending Courses

Cyber Security Course

Cyber Security

  • Introduction to cybersecurity
  • Cryptography and Secure Communication 
  • Cloud Computing Architectural Framework
  • Security Architectures and Models
Cyber Security Course

Upcoming Class

13 days 04 Jan 2025

QA Course

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing
QA Course

Upcoming Class

6 days 28 Dec 2024

Salesforce Course

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL
Salesforce Course

Upcoming Class

8 days 30 Dec 2024

Business Analyst Course

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum
Business Analyst Course

Upcoming Class

5 days 27 Dec 2024

MS SQL Server Course

MS SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design
MS SQL Server Course

Upcoming Class

5 days 27 Dec 2024

Data Science Course

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning
Data Science Course

Upcoming Class

12 days 03 Jan 2025

DevOps Course

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing
DevOps Course

Upcoming Class

4 days 26 Dec 2024

Hadoop Course

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation
Hadoop Course

Upcoming Class

6 days 28 Dec 2024

Python Course

Python

  • Features of Python
  • Python Editors and IDEs
  • Data types and Variables
  • Python File Operation
Python Course

Upcoming Class

5 days 27 Dec 2024

Artificial Intelligence Course

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks
Artificial Intelligence Course

Upcoming Class

13 days 04 Jan 2025

Machine Learning Course

Machine Learning

  • Introduction to Machine Learning & Python
  • Machine Learning: Supervised Learning
  • Machine Learning: Unsupervised Learning
Machine Learning Course

Upcoming Class

5 days 27 Dec 2024

 Tableau Course

Tableau

  • Introduction to Tableau Desktop
  • Data Transformation Methods
  • Configuring tableau server
  • Integration with R & Hadoop
 Tableau Course

Upcoming Class

6 days 28 Dec 2024

Search Posts

Reset

Receive Latest Materials and Offers on AWS Course

Interviews