Getting Started with the AWS CLI

Getting Started with the AWS CLI

Sebin Thomas

AWS CLI Installation Guide

This guide walks you through installing and configuring the AWS Command Line Interface (CLI) on your system.

Prerequisites

Make sure you have:

  • Python (3.8 or later)
  • pip (the Python package installer)

Step 1: Installing the AWS CLI

To install the AWS CLI using pip, run:

1
python -m pip install awscli

For a system-wide installation, use:

1
sudo python -m pip install awscli

To install for your user only, use:

1
python -m pip install --user awscli

Alternative Installations:
For macOS:
Download and run the installer directly from AWS:

1
2
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /

For Windows:
Download the MSI installer from the AWS CLI website and follow the installation prompts.

For Linux:

1
sudo apt install awscli

Step 2: Verifying the Installation

To confirm that the AWS CLI is installed, run:

1
aws --version

This should display the version number of the AWS CLI installed on your system.

Step 3: Configuring the AWS CLI

Run the following command to set up your AWS credentials and default settings:

1
2
3
4
5
aws configure
AWS Access Key ID [****************766Q]: MYACCESSKEY
AWS Secret Access Key [****************DT9d]: MYSECRETKEY
Default region name [us-west-2]:
Default output format [None]:

Alternate Configuration Options
You can also configure AWS credentials using environment variables or by editing the configuration files in ~/.aws/.

Environment Variables:
Set credentials in the shell for temporary configuration:

1
2
export AWS_ACCESS_KEY_ID=<access_key>
export AWS_SECRET_ACCESS_KEY=<secret_key>

Shared Credentials File:
You can store your AWS credentials in a shared credentials file. Create or edit the file located at ~/.aws/credentials, and format it as follows:

1
2
3
[default]
aws_access_key_id=MYACCESSKEY
aws_secret_access_key=MYSECRETKEY

To view the details of the Current IAM Identity

This command retrieves the AWS account ID, IAM user or role ID, and ARN for the currently authenticated identity.

1
aws sts get-caller-identity

If you have configured using –profile option to configure then

1
aws sts get-caller-identity --profile AWS

Our output will be something like this:

1
2
3
4
5
6
aws sts get-caller-identity --profile AWS
{
"UserId": "AIDABCDEFGHIJKLMNO1234",
"Account": "123456789012",
"Arn": "arn:aws:iam::123456789012:user/myprofile-user"
}

Stay tuned for more write-ups on cloud security challenges from PwnedLabs!

  • Title: Getting Started with the AWS CLI
  • Author: Sebin Thomas
  • Created at : 2024-11-01 17:29:00
  • Updated at : 2025-02-24 21:01:48
  • Link: https://0xsebin-blogs.vercel.app//Getting-Started-with-the-AWS-CLI
  • License: All Rights Reserved © Sebin Thomas
Comments