DevDocsDev Docs

AWS CLI Setup

Install and configure the AWS Command Line Interface

The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services from the command line.

Prerequisites

You'll need an AWS account and IAM credentials before configuring the CLI.

Installation

Install with Homebrew (Recommended)
brew install awscli

Or download the official installer:

Manual Installation
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
Download and Install
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

For ARM-based systems:

ARM64 Installation
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
MSI Installer
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi

Or download from the AWS CLI page.

Configuration

Run Configuration Wizard

Configure AWS CLI
aws configure

You'll be prompted for:

  • AWS Access Key ID: Your access key
  • AWS Secret Access Key: Your secret key
  • Default region name: e.g., us-east-1
  • Default output format: json, yaml, text, or table

Verify Configuration

Test Your Setup
aws sts get-caller-identity

Expected output:

Success Response
{
    "UserId": "AIDAEXAMPLEID",
    "Account": "123456789012",
    "Arn": "arn:aws:iam::123456789012:user/username"
}

Named Profiles

Create multiple profiles for different environments:

Configure Named Profile
# Configure a named profile
aws configure --profile production

# Use a named profile
aws s3 ls --profile production

# Set default profile
export AWS_PROFILE=production

Configuration Files

AWS CLI stores configuration in two files:

config
credentials
~/.aws/credentials
[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_KEY

[production]
aws_access_key_id = PROD_ACCESS_KEY
aws_secret_access_key = PROD_SECRET_KEY
~/.aws/config
[default]
region = us-east-1
output = json

[profile production]
region = us-west-2
output = yaml

Security

Never commit AWS credentials to version control. Use environment variables or AWS profiles instead.

Verify Installation

Check Version
aws --version

Common Options

OptionDescription
--profileUse a specific profile
--regionOverride the default region
--outputOutput format (json, yaml, text, table)
--queryJMESPath query for filtering output
--dry-runCheck permissions without making changes

Environment Variables

Set Credentials via Environment
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export AWS_DEFAULT_REGION="us-east-1"
Use a Specific Profile
export AWS_PROFILE="production"

Credential Precedence

AWS CLI uses credentials in this order: CLI options → Environment variables → Config files → Instance metadata (EC2/ECS).

Next Steps

On this page