AWS is renowned for its robust cloud services, offering a wide range of tools to enhance business operations and enhance application development. At the core of this ecosystem lies the AWS Command Line Interface (CLI), a versatile tool that enables direct interaction with AWS services from your command prompt or terminal.
In this blog, we’ll walk you through installing the AWS CLI on various operating systems, including Windows, macOS, and Linux. Once set up, you’ll discover how the AWS CLI simplifies cloud resource management with straightforward commands. From optimizing data storage to scaling applications, the AWS CLI empowers you to make the most of AWS capabilities without delving into technical complexities.
Whether you’re a business professional seeking streamlined cloud operations or an individual curious about AWS possibilities, this guide is designed for you. Join us as we unleash the potential of AWS CLI and elevate your cloud experience.
Installing AWS CLI
This tutorial will show you the steps to install the AWS CLI on your machine no matter the OS. Note that this section provides screenshots and examples for Windows installation only.
Windows
To install the AWS CLI onto your local machine, execute the following command in your terminal:
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
This will result in the following popup on your machine:
Accept the License Agreement, and click on Next until you reach the window shown below. Click on ‘Install’ to complete the installation process.
When the installation is complete, a window like the one below will appear. Click on ‘Finish’.
Linux
First up, you must download the installer file. To do this, you can either download it from your browser by clicking this link https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip or by executing this command in your terminal:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o ".zip"
Then unzip the installed package using this command:
unzip .zip
Run the installation program after naviagting to your unzipped folder using the cd
command.
cd
sudo ./aws/install
To verify that the installation is completed successfully, run this command:
aws --version
MacOS
To install AWS CLI on MacOS, you must first install the .pkg file from AWS on the following link https://awscli.amazonaws.com/AWSCLIV2.pkg.
Then, run the file and follow the instructions in the menu that pops up.
Accept the License:
You can either install AWS CLI for all machine users or for your current user only
After specifying the destination directory for your installation and clicking ‘Install’, athe end of the installation, you will the final page of the popup menu. You can now safely close this menu.
To verify that AWS CLI is accessible to the system, run the below command in your terminal:
which aws
You should get a path to AWS as an output. For example:
Verifying Installation
For all operating systems, to ensure that the installation is completed with no errors, execute the following command in your terminal:
aws --version
You should get an output printed to your terminal similar to the one below, indicating that a recent version of aws-cli has been installed. You may need to close and reopen your terminal before running the command for this to work.
Configuring AWS CLI
Configuring the AWS CLI is a crucial initial step for using this powerful tool, as it involves setting up authentication credentials and customizing preferences. This allows you to securely interact with AWS services.
Run the command below in your terminal:
aws configure
You will then be prompted to enter your IAM User’s access key and secret access key:
You can also use your credentials file to configure AWS CLI using the command below:
aws configure import --csv file://credentials.csv
Help!
Using AWS CLI may seem daunting with the variety of commands and services available. This is where the help
command comes into play.
You can use it to get a general overview of how the AWS CLI works:
aws help
You can see what commands you can use with a specific AWS service like S3:
aws s3 help
You can also use the help
command to check options you can add to a specific service’s command:
aws s3 mb help
The output shows what the command does as well as the flags you can use to customize your command execution:
AWS CLI in Action
This section will give some examples of using the AWS CLI with the AWS Identity and Access Management (IAM) service. Note that the IAM User, whose credentials you used to configure the AWS CLI, must have the corresponding permissions to execute commands using AWS CLI.
You can use the AWS CLI to generate a credential report using the command aws iam generate-credential-report
. The initial output is that the task has started.
After a while, when the command is executed again, the status changes to complete:
With the right access, you can list groups and users aws iam list-groups
and aws iam list-users
.
You can also view roles using the aws iam list-roles
command. This will return an array of roles, with each role name, ID, and associated policy document.
There are many other services to discover and commands to take advantage of depending on your cloud architecture and business needs.
Conclusion
In conclusion, the AWS Command Line Interface (CLI) is a vital tool for anyone working with AWS. The interface’s simplicity and versatility make it an invaluable asset for cloud administrators, developers, and enthusiasts alike.
Embrace the power of the AWS CLI to unlock endless possibilities, elevate your AWS experience, and boost your productivity. With the AWS CLI at your fingertips, you can effortlessly manage your AWS resources.