How to Install AWS CLI V2

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.

How to install AWS CLI

  1. Install AWS CLI

    Download and run the installation script.

  2. Configure and Test AWS CLI

    Check that the AWS CLI is working

  3. Configure AWS CLI Security Profile

    Set the aws_access_key_id and aws_secret_access_key for each AWS account profile

  4. Troubleshooting

    Fix Invalid apiVersion, Can’t find aws binary

  5. Next Steps

    Deploy an AWS EKS cluster with Terraform.

Install AWS CLI

To install follow the official installation instructions or run the install script.

Command line installation of AWS CLI

$ curl "" -o ""
$ unzip
$ sudo ./aws/install

Check the AWS CLI

Check that the AWS CLI has been installed:

$ 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.

$ 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.


aws_access_key_id = AK************JT
aws_secret_access_key = HZJK****************************adsg12621a

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:

$ 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


[profile ditwl-test]


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:

$ kubectl version
error: exec plugin: invalid apiVersion ""

Update the AWS CLI to the latest version by uninstalling and installing again.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Cloud Tutorials

Using the Terraform aws_route53_delegation_set, aws_route53_zone, and aws_route53_record resource blocks to configure DNS in AWS.
Using the Terraform aws_db_instance resource block to configure, launch, and secure RDS instances.
How to use the Terraform aws_instance resource block to configure, launch, and secure EC2 instances.
How to configure and use the Terraform aws_ami data source block to find and use AWS AMIs as templates (root volume snapshot with operating system and applications) for EC2 instances.
How to configure and use the Terraform aws_key_pair resource block to create and manage AWS Key Pairs for performing SSH Public Key Authentication into EC2 instances.
Javier Ruiz Cloud and SaaS Expert

Javier Ruiz

IT Wonder Lab tutorials are based on the diverse experience of Javier Ruiz, who founded and bootstrapped a SaaS company in the energy sector. His company, later acquired by a NASDAQ traded company, managed over €2 billion per year of electricity for prominent energy producers across Europe and America. Javier has over 25 years of experience in building and managing IT companies, developing cloud infrastructure, leading cross-functional teams, and transitioning his own company from on-premises, consulting, and custom software development to a successful SaaS model that scaled globally.

Are you looking for cloud automation best practices tailored to your company?

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram