Managing Amazon Web Services (AWS) from the command line can be highly efficient and convenient. The AWS Command Line Interface (CLI) allows you to interact with AWS services directly from your terminal or command prompt. This blog will guide you through the installation of AWS CLI, connecting it to your AWS account, and configuring it for seamless use.

Step 1: Install AWS CLI

For Windows Users:

  1. Download the Installer
  2. Run the Installer
    • Double-click the downloaded .msi file and follow the installation wizard.
  3. Verify Installation
    • Open Command Prompt and type:
      aws –version
    • You should see output similar to:
      aws-cli/2.x.x Python/3.x.x Windows/10

For macOS Users:

  1. Use Homebrew
    • Open your terminal and run:
      brew install awscli
  2. Verify Installation
    • Run the following command in the terminal:
      aws –version

For Linux Users:

  1. Download and Install

Open your terminal and run:
curl “https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip” -o “awscliv2.zip”

unzip awscliv2.zip

    • sudo ./aws/install

2. Verify Installation

    • Run:
      aws –version

Step 2: Create or Locate Your Access and Secret Keys

To connect AWS CLI with your AWS account, you need an Access Key and a Secret Key. These keys can be created in the AWS Management Console.

  1. Login to AWS Console
  2. Access IAM (Identity and Access Management)
    • Search for “IAM” in the AWS Console search bar and select it.
  3. Create an IAM User
    • Go to Users and click Add users.
    • Provide a name for the user (e.g., cli-user).
    • Select Programmatic access as the access type.
  4. Attach Policies
    • Choose the appropriate policies for the user, such as AdministratorAccess (if applicable).
    • Click Next: Tags and then Next: Review.
  5. Save the Keys
    • After the user is created, download the .csv file containing the Access Key ID and Secret Access Key, or copy them securely.

Important: Keep your secret key confidential. Do not share it or expose it in code repositories.

Step 3: Configure AWS CLI

  1. Open Terminal or Command Prompt
  2. Run AWS Configure
    • Enter the following command:
      aws configure
  3. Provide Credentials
    • Enter the requested information:
      • Access Key ID: (Enter your access key)
      • Secret Access Key: (Enter your secret key)
      • Default region: (e.g., us-east-1)
      • Output format: (e.g., json)

Example:
AWS Access Key ID [None]: AKIAxxxxxxxxxxxxxxx
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-east-1

4. Default output format [None]: json

5. Test the Configuration

    • Run a simple command to test the connection:
      aws s3 ls
    • If your CLI is connected correctly, you should see a list of S3 buckets (if any exist in your account).

With AWS CLI installed and configured, you can now manage your AWS resources efficiently from the command line. Whether you’re scripting repetitive tasks or exploring AWS services, the CLI is a powerful tool to have in your arsenal. Ensure your access keys are secure, and always follow best practices for managing credentials.

Next article – Step 6: How to Create a Windows 11 Virtual Instance Using Oracle VirtualBox

We are here to help!

Contact us to help you set up your AWS WorkSpaces account.