Configuring AWS CLI

How to start using this powerful command-line tool for your AWS needs

Cloud Digests
4 min readOct 28, 2020
Photo by Markus Spiske on Unsplash

Not a fan of the AWS Management Console? Maybe it’s too much of a pain to click through the set-up wizard 10 times just to launch 10 EC2 instances. Well, AWS CLI is just the tool for you.

AWS CLI is a tool which allows you to manage and monitor your AWS services from a terminal session in your client. The benefit of AWS CLI is that you can run automation scripts or shells to easily provision resources. AWS CLI also provides direct access to AWS Service APIs and extended functionality for your needs.

AWS CLI is easy to install and configure for use. It helps you save time by allowing you to just open a terminal session and complete tasks like getting the contents of an S3 bucket or create EC2 instances instead of having to log into the AWS Management Console and click through many tabs. AWS CLI also gives you the ability to automate entire processes and deployments through scripts, which make it easy to automate your cloud infrastructure. AWS CLI also provides support for all the AWS services from one simple tool.

Some examples of tasks you can complete with AWS CLI include deleting an S3 bucket, creating EC2 instances, listing EC2 instances, creating Security Groups, and pretty much anything else.

I will be going through how to install AWS CLI and configure it for your use. This method will work regardless of the OS you are using. AWS CLI supports Windows, macOS, Linux and Amazon Linux. I will be covering all 3 methods briefly.

Installing AWS CLI

Installing the AWS CLI on whichever OS you are using is extremely easy and quick. Please follow the steps for the OS you are using, be it Linux, Windows or macOS

Linux

To install the latest version of AWS CLI on Linux, run this code below:

$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" 
unzip awscliv2.zip
sudo ./aws/install

Now, run aws --version to check if the installation was successful. If it was, you should see this reply:

If you require additional help, you can view the AWS Documentation here.

Windows

On Windows, we can use the MSI installer to easily download AWS CLI. Download the latest AWS CLI MSI Installer here and follow the on-screen instructions.

By default, AWS CLI installs to C:\Program File\Amazon\AWSCLIV2

To check if AWS CLI has been installed, open Command Prompt and type aws --version and you should see a similar output to the one below.

If you require additional help, you can view the AWS Documentation here.

macOS

To install AWS CLI on your macOS device, download the pkg file from here. Double click the downloaded pkg file to launch the installer. Follow the on-screen instructions.

You can choose to install for all users or only the current user. Take note that if you install for all users, you require sudo privileges.

To check if AWS CLI has been installed, you can run which aws and aws --vesrion

Configuring AWS CLI

After installing AWS CLI, you need to configure it for use. This is very simple and can be done with a few simple steps.

First, you need to get the access key ID and secret access key of an IAM user. Go to IAM →Users →Security Credentials →Create Access Key

You will be shown a screen with your Access Key and Secret Access Key.

DISCLAIMER: DO NOT SHARE THESE 2 VALUES. I deleted them immediately after the screenshot.

Copy these 2 values into a notepad, you need them soon.

Now, you are ready to configure AWS CLI for use. Open a Command prompt and run aws configure and key in the relevant information.

  • Access Key ID: <The value you copied just now>
  • Secret Access Key: <The value you copied just now>
  • Default Region Name: <The Region you are using, like us-east-1 >
  • Default output format: <whichever format you want, I usually use json and text>

After that, you are done already. If you ever want to reconfigure the above information, just run aws configure again.

Conclusion

Congratulations! AWS CLI is now ready for use. This is just the easiest and most basic way of setting up AWS CLI for your use. There are many different things you can do, such as installing a specific version of the AWS CLI or using credential files to configure AWS CLI. You can also create different profiles for use and even for specific services.

The AWS CLI is a very powerful tool that can be used to launch and configure AWS resources. To find out more about AWS CLI, you can read the AWS Documentation here.

--

--

Cloud Digests

Making Cloud Computing easy to learn and adopt for everybody, tech trained or otherwise. Simple and quick to understand content