Install and Configure AWS CLI on Windows EC2 Machine

Here are step-by-step instructions:

Installation of AWS CLI

  1. Go to the AWS CLI download page: https://aws.amazon.com/cli/
  2. Choose the appropriate Windows installer for your system and download it.
  3. Run the installer and follow the prompts to complete the installation.

Validation of AWS CLI setup

To check the version of the AWS CLI installed on your Windows machine, open a command prompt or PowerShell terminal and run the following command:

        aws --version

This will display the version number of the AWS CLI installed on your machine, along with the version of Python that it is using. For example:

       aws-cli/2.2.18 Python/3.8.8 Windows/10 exe/AMD64 prompt/off

If you get an error message or the command does not display the version information, it could be due to below reasons.

  1. The AWS CLI is not in your system’s PATH: Most of the time rebooting machine after AWS CLI setup fixes this. However if reboot is not possible then you can add the AWS CLI executable path to your system’s PATH environment variable. To do this, follow these steps:
    • a. Open the Start menu and search for “Environment Variables”.
    • b. Click on “Edit the system environment variables”.
    • c. Click on the “Environment Variables” button.
    • d. Under “System Variables”, scroll down and find the “Path” variable. Select it and click on “Edit”.
    • e. Click on “New” and enter the path to the AWS CLI executable. The default installation path is C:\Program Files\Amazon\AWSCLI\bin.
    • f. Click on “OK” to close all windows.
    • g. Open a new command prompt or PowerShell terminal and run aws --version again.
  2. The AWS CLI installation is corrupted: If you have installed the AWS CLI and added it to your system’s PATH, but are still unable to run aws --version, it could be because the installation is corrupted. In this case, you can try uninstalling and reinstalling the AWS CLI.

Configure AWS CLI with AWS account

  1. Type the command aws configure to start the configuration process:
    • a. This command will prompt you to enter your AWS Access Key ID, Secret Access Key, Default region name, and Default output format.
    • b. You can find your Access Key ID and Secret Access Key in the AWS Management Console. To access them, log in to the console, click on your username in the top right corner, and choose “My Security Credentials” from the dropdown menu.
    • c. The default region name and output format can be set according to your preferences. For example, you can set the region to “us-west-2” and the output format to “json”.
  2. Once you have entered your AWS credentials, the AWS CLI will be configured on your Windows machine.
    • a. The configuration details will be stored in a file called “config” in the “.aws” directory in your user home directory.
    • b. You can edit this file directly if you need to modify the configuration in the future.
  3. To test the configuration, you can run a command such as aws s3 ls to list the contents of your AWS S3 buckets.
    • a. This command will list all the buckets in your default region.
    • b. You can replace “s3” with other AWS services, such as “ec2”, “rds”, or “lambda”, to interact with those services through the CLI.

I hope this will contribute to your AWS learning. Happy Learning !