Last updated on April 27, 2023
What is AWS CLI?
AWS Command Line Interface (CLI) is a tool used to manage and interact with AWS Services using the command line. Users more comfortable in the command line can leverage the AWS CLI as it offers the exact scope of functionality as the AWS Console.
AWS CLI requires minimal configuration before you can use it. Installed it on your local machine running on Linux, Windows, and macOS.
What is the Difference Between AWS CLI and AWS CloudShell?
Likewise, AWS CloudShell is another tool you can use to manage AWS resources using the command line interface. But unlike AWS CLI, AWS CloudShell can run directly from the browser. Here are the notable differences between AWS CLI and AWS CloudShell.
AWS CLI |
AWS CloudShell |
Requires installation |
No installation required |
Runs on local machines/EC2 instance |
Runs directly on the browser |
Requires Access Keys/Roles |
Pre-authenticated. Use the same credentials used in signing in on AWS Console. |
How to Install AWS CLI
As mentioned previously, AWS CLI supports Linux, Windows, and macOS. For this example, we will install the AWS CLI on a local machine running on the Windows operating system.
You can download the AWS CLI installer from here or run the following command from your CMD.
The installation wizard will pop up. Follow the onscreen procedure for proper installation.
Once installation is done, check the version to verify using your CMD.
Set up the Access Keys using the following command. You will be prompted to provide AWS Access Key ID and Secret Access Key. Your CLI will use these to authenticate for you to interact with AWS Services. Additionally, you can also set the default region and output format.
Optionally, you can use the –profile option to save a configuration for a specific profile or account. AWS CLI will use the default profile if you don’t use this option.
On a Windows machine, you can view the saved profile from the directory below.
How AWS CLI Interacts with AWS Services
Here’s an example of how to launch an EC2 instance using AWS CLI.
Generate the keypair that the instance will use. This key pair will be downloaded on your local machine the same as when you create a new key pair from the AWS Console.
Optional: Run the command below to verify your key pair
Launch an EC2 instance using the command below.
In this example, a t2.micro EC2 instance is launched. You may see an output similar below.