AWS Command Line Interface (AWS CLI) is a fantastic tool that will let you interact with AWS services using commands in your Command line tool. These AWS CLI Commands can be executed from any of the Command-Line tools in your operating system If you have installed the AWS CLI SDK installed properly on it. In this article, we will discuss how to install and configure AWS CLI on different platforms. AWS released two different versions of the AWS CLI till now. In this article, we will discuss How to install and Configure AWS CLI Version 2.
Table of Contents
Installing AWS CLI Version 2 with Docker.
As we know, Docker is a fantastic tool that will create a lightweight virtual environment that is totally platform-independent. So, to Install and use AWS CLI, Docker will help us with the latest AWS CLI without even installing it on the host operating system.
- All you need is Docker installed on your host machine. There is nothing else required if you are using Docker to install AWS CLI.
As we already mentioned, you don’t have to install any software or application to run AWS CLI with docker. But you need to install the Official Docker Image for AWS CLI. For the same follow the below steps.
- Pull the Docker Image by using the following command
$ docker pull amazon/aws-cli
- Run the Docker run Command with the AWS CLI command you need to execute. Example.
$ docker run --rm -it amazon/aws-cli s3 ls
That’s all, the above command will give you the list of objects available in the AWS account.
However, Running AWS CLI on Docker container has some solvable issues, which are sharing files, Credentials, Environment Variables from the Host to Container. For the same, you should use the volume sharing arguments with the docker command. For example,
$ docker run --rm -it -v ~/.aws:/root/.aws amazon/aws-cli command
So, here, the credentials and other information saved inside
~/.aws folder will be stored inside
/root/.aws in the Docker Container.
Installing AWS CLI Version 2 on Linux.
Before Installing the AWS CLI on Linux, Let discuss the prerequisites.
- Uninstall the AWS CLI Version 1 If you have installed it already.
- Install unzip tool if you don’t have that in your operating system by default
- Install Libraries like
- OS Architecture Linux x86 (64-bit) or Linux ARM
On Linux x86 (64-bit)
To install AWS CLI on Linux x86 (64-bit), use the following commands.
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install
on Linux ARM
To install AWS CLI on Linux ARM, use the following commands.
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install
To install the different versions, Visit the AWS CLI Github repository release page to get the desired version of AWS CLI.
Installing AWS CLI Version 2 on macOS.
Before Installing the AWS CLI on macOS, Let discuss the prerequisites.
- 64-bit macOS is required
- Xcode or developer tools enabled.
Installing with user interface
- Go to your browser in macOS and enter this link – https://awscli.amazonaws.com/AWSCLIV2.pkg
- Double click the downloaded file to launch the installer.
- Then, follow the instruction.
Installing with macOS Terminal
To install AWS CLI on the macOS, run the following commands one by one.
$ curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg" $ sudo installer -pkg AWSCLIV2.pkg -target /
From the either ways, you can test the installation by running
aws --version in the command line. This should return the installed version, If it is installed properly.
Installing AWS CLI Version 2 on Windows.
Before Installing the AWS CLI on Windows, Let discuss the prerequisites.
- 64-bit Windows is required
- Windows XP or Later Required
- Administrator Access Required
Installing AWS CLI in windows is very easy. All you need to do is to follow the below steps.
- Download the Installer from the amazon website – https://awscli.amazonaws.com/AWSCLIV2.msi
- Double click the Installer you downloaded
- Follow the instructions.
That’s all the Installation on AWS CLI in the Windows OS. And to confirm the Installation, Just run
aws –version in the command prompt and It should return the version number if it is installed properly.
Configuring AWS CLI
Once you install the AWS CLI, You can configure the AWS CLI to point your AWS Account with the credentials and other details where you want to work. For the same, Just enter the aws configure command in the command line and it will ask you the information one by one. Example,
$ aws configure AWS Access Key ID [None]: XXXXXXXXXXXXXXXXXXXXXXXXXXX Secret Access Key [None]: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Default region name [None]: us-east-1 Default output format [None]: json
This will create a AWS configuration file in the user’s home directory. (
You may wonder What and where to get the Access Key and Secret Key of the AWS Account. To know or generate your AWS Access Key and Secret Key, follow the below instructions.
To get AWS Access key and Secret Key:
- Login to AWS Console
- Go to IAM services
- Select Users in the left Navigation panel
- Chose the User you want to give access for
- Select Security Credentials Tab
- Select Create Access key from Access Key Section
- Click Show to reveal the Access Key and Secret Key and save it.
That’s all the Basic configuration of AWS CLI.
In this article, we have discussed How to Install and Configure Amazon AWS CLI on various Operating systems like Windows, macOS, Linux, and Docker. In our upcoming article, we will discuss Important Commands to remember while using AWS CLI and automating AWS Engineering with AWS CLI along with some scripting language. We will discuss the same in our upcoming article. Stay tuned and subscribe DigitalVarys for more articles and study materials on DevOps, Agile, DevSecOps, and App Development.
Experienced DevSecOps Practitioner, Tech Blogger, Expertise in Designing Solutions in Public and Private Cloud. Opensource Community Contributor.