📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials AWS Solutions Architect AWS CLI Deep Dive

AWS CLI Deep Dive

3 min read
Master the AWS CLI for automation, scripting, and production management. Learn named profiles, essential commands, and output filtering.

AWS CLI — Command Line Power

The AWS CLI lets you control ALL AWS services from your terminal. Every button click in the console has an equivalent CLI command — and CLI commands can be scripted and automated.

Teacher Note: The CLI is like having a direct phone line to every AWS engineer instead of going through a website. Faster, scriptable, and essential for DevOps and automation workflows.

CLI Installation and Configuration

# Install AWS CLI v2
# Linux/Mac:
curl 'https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip' -o 'awscliv2.zip'
unzip awscliv2.zip && sudo ./aws/install

# Configure with your credentials
aws configure
# AWS Access Key ID: AKIA...
# AWS Secret Access Key: your-secret-key
# Default region: us-east-1
# Default output format: json

# Credentials stored in: ~/.aws/credentials
# Config stored in: ~/.aws/config

Named Profiles — Multiple Accounts

# Configure a named profile for a second account
aws configure --profile production

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

# Set default profile for session
export AWS_PROFILE=production

Essential CLI Commands for Architects

# EC2
aws ec2 describe-instances --filters Name=instance-state-name,Values=running
aws ec2 start-instances --instance-ids i-1234567890abcdef0
aws ec2 stop-instances --instance-ids i-1234567890abcdef0

# S3
aws s3 ls s3://my-bucket
aws s3 cp file.txt s3://my-bucket/
aws s3 sync ./local-folder s3://my-bucket/

# VPC
aws ec2 describe-vpcs
aws ec2 describe-subnets --filters Name=vpc-id,Values=vpc-12345678

# IAM
aws iam list-users
aws iam get-user --user-name alice

# Useful flags
aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId'
aws ec2 describe-instances --output table
Exam Tip: CLI pagination: use --max-items and --starting-token for large result sets. Use paginators in boto3 for automatic pagination. The --query flag uses JMESPath for filtering output — very useful for scripting.