# How to Install AWS CLI V2

> How to install the AWS CLI (Command Line Interface) to interact with Amazon Web Services through the command line.

- Source: https://www.itwonderlab.com/install-aws-cli/
- Published: 2023-11-22
- Updated: 2026-10-05
- Author: Javier Ruiz Jiménez (https://www.javierruizjimenez.com/)
- Site: IT Wonder Lab (https://www.itwonderlab.com/)

---

## Install AWS CLI V2 for managing AWS services

The AWS CLI (Command Line Interface) is a tool that lets you interact with Amazon Web Services through the command line. It allows you to manage AWS services, automate tasks, and access various AWS functionalities using commands typed into a terminal or command prompt.

### Install AWS CLI

To install follow the [official installation instructions](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) or run the install script.

#### Command line installation of AWS CLI

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

### Check the AWS CLI

Check that the AWS CLI has been installed:

```shell
$ aws --version
aws-cli/2.13.38 Python/3.11.6 Linux/5.15.0-88-generic exe/x86_64.ubuntu.22 prompt/off
```

### Configure AWS CLI Security

Set the values you provide for the AWS Access Key ID and the AWS Secret Access Key. Values will be written to the shared credentials file (`~/.aws/credentials`) using the “default” profile.

> [!TIP]
> Access keys do not expire. If your organization uses AWS IAM Identity Center (SSO), run `aws configure sso` instead: the CLI then gets temporary credentials after a browser login, and no keys are stored on your computer. See [AWS IAM](https://www.itwonderlab.com/aws-iam/).

```shell
$ aws configure
AWS Access Key ID [None]: BKA******************VK    
AWS Secret Access Key [None]: VHYLs**************************9z4Ga
Default region name [None]: 
Default output format [None]:
```

#### The AWS CLI credentials file

AWS CLI uses ~/.aws/credentials file for storing the `aws_access_key_id` and `aws_secret_access_key` for each AWS account that it manages, the values are stored under `[profile name]`. The default profile is used when the user doesn’t specify a specific profile.

The file can be manually modified or the `aws configure` command can be used.

Example:

```
[default]
aws_access_key_id = AK************JT
aws_secret_access_key = HZJK****************************adsg12621a

[ditwl_infradmin]
aws_access_key_id = AK*************4
aws_secret_access_key = PI********************mc4
account_id = 12345678910
```

Execute `aws configure help` for advanced options.

#### Set a specific profile configuration for AWS CLI

Create a new AWS CLI profile:

```shell
$ aws configure --profile ditwl-test
AWS Access Key ID [None]: AK*************4
AWS Secret Access Key [None]: PI********************mc4
Default region name [None]: 
Default output format [None]:
```

#### The AWS CLI config file

AWS CLI uses `~/.aws/config` file for storing the advanced options for each AWS profile (in square brackets) that it manages, for example:

```
[profile ditwl_infradmin]
region = us-east-1

[default]

[profile ditwl-test]
```

### Troubleshooting

#### Kubectl shows an invalid apiVersion

The Kubernetes `kubectl` command checks connectivity with all the clusters in the `kubeconfig` file, if any of the clusters is an Amazon EKS then it can show this error:

```shell
$ kubectl version
error: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1"
```

Update the AWS CLI to the latest version with the install script and the `--update` option (`sudo ./aws/install --update`).

#### Can’t find aws binary

When running the `aws` command: `bash: /usr/bin/aws: No such file or directory`, fix by following these instructions:

-   Make sure that the AWS CLI is installed
-   Clean the bash file cache so that the `aws` binary location is updated, run `hash aws` and test again

### Next Steps

-   [Deploy an AWS EKS Cluster with Terraform](https://www.itwonderlab.com/terraform-eks/)
-   [AWS with Terraform: The Essential Guide (3/21) – Terraform AWS Provider](https://www.itwonderlab.com/aws-terraform-tutorial-terraform-aws-provider/)
