Setup AWS CLI for the ability to run AWS Commands

Durga Gadiraju
Data Engineering on Cloud
4 min readMar 26, 2022

--

Let us go ahead and Setup AWS CLI for the ability to run AWS Commands on multiple OS Platforms such as Windows, Mac as well as Ubuntu.

All IT Engineers who would like to work with AWS should have AWS CLI Setup for following reasons.

  • Ability to manage services such as EMR, RDS, EC2 Instances, etc.
  • Ability to manage components of services such as s3 buckets.

This article is part of Data Engineering on Cloud Medium Publication co-managed by ITVersity Inc (Training and Staffing) and Analytiqs Inc (Data Services Boutique)

Overview of AWS CLI

AWS CLI (Command Line Interface) is primarily to run AWS Commands to manage the services such as ec2, s3, etc. Here are the high level steps involved in setting up AWS CLI.

  • Install AWS CLI — There are multiple ways to install AWS CLI. One of the way which is covered in this article is by using pip or pip3.
  • Configure AWS CLI — AWS CLI is being installed to manage AWS Services. We are supposed to authenticated and authorized to manage AWS Services. We need to configure AWS CLI with AWS Access Key and Security Key.
  • Validate AWS CLI — Once installed and configured, we need to validate whether AWS CLI is working as expected or not.

Keep in mind that we need to have Python 3 and pip for Python 3 are installed on the target machine where we would like to use AWS CLI.

Install AWS CLI on Windows 10 or 11

Let us go ahead and see how to install on AWS CLI on Windows. We will use wsl to keep it simple and uniform with other platforms.

wsl stands for Windows Subsystem for Linux. You can install Ubuntu based Virtual Machines on Windows 10 later using wsl.

  • You can follow the instructions and set up Ubuntu 20.04 on Windows 11 using wsl
  • Ubuntu 18.04 or later comes with Python 3 out of the box. The version of Python might be different between 18.04/20.04.
  • If you are planning to use wsl, make sure to setup Ubuntu VM and go to Install AWS CLI on Ubuntu section in this article.

Install AWS CLI on Mac

Let us go ahead and understand how to install AWS CLI on Mac.

  • First we need to make sure Python 3 is installed on Mac. You can launch terminal and run python3 --version command to confirm the version of Python that is currently setup. You can also run python --version in case the python3 --version complains about command not found. However you need to make sure the Python version is 3.6 or later.
  • You can validate if pip is working or not by running python3 -m pip --version. Make sure to confirm, if pip is mapped to the Python3 version which you have seen earlier.
  • Now you can run python3 -m pip install awscli to install AWS CLI.
  • Make sure to go through the logs to confirm there are no errors. Also, run aws --version to confirm AWS CLI is installed successfully.

Install AWS CLI on Ubuntu 20.04

Let us go ahead and understand how to install awscli on Ubuntu 20.04. We will use pip to install awscli.

  • We might not have pip available as part of Ubuntu 20.04. By default Ubuntu 20.04 will have Python 3.8.
  • You can login into Ubuntu 20.04 system and run python3 command to check the version of Python.
  • If you are using Ubuntu 20.04 setup using wsl, you can launch Ubuntu 20.04 and run python3 command to check the version of Python.
  • You can run sudo apt update && apt install python3-pip -y to install pip on Ubuntu 20.04. You can validate whether pip is installed or not using python3 -m pip --version.
  • Now you can run python3 -m pip install awscli to install AWS CLI.
  • Make sure to go through the logs to confirm there are no errors.
  • Logout and login again to make sure AWS CLI is accessible.
  • Also, run aws --version to confirm AWS CLI is installed successfully.

Configure AWS CLI

As AWS CLI is successfully installed now it is time for us to configure so that we can manage AWS CLI Services.

  • Login into the AWS Web Console.
  • Create IAM User with appropriate roles and privileges. If you are new try to create account as administrator. Make sure to capture access key and secure key.
  • Run aws configure command to configure AWS CLI. It will prompt for Access Key, Secret Key, Region, etc. You need to make sure you paste Access Key and Secret Key while region is optional.

Validate AWS CLI

Once AWS CLI is successfully installed and configured, we can validate by running some commands.

  • To list the s3 buckets aws s3 ls.
  • To list AWS ec2 instances aws ec2 describe-instances.
  • We can also stop and start ec2 instances using appropriate commands.

--

--