This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

AWS CLI Core Commands Cheat Sheet

A quick reference guide for AWS CLI: EC2 instance control, S3 bucket and object management, named configuration profiles, ECS, and Elastic Beanstalk.

· Published

A quick reference guide for common command-line administration tasks using the official AWS Command Line Interface (aws).

Installation & Configuration

# macOS (Homebrew)
brew install awscli

# Initialize credentials and default region
aws configure

# Configure named profiles
aws configure --profile staging
aws configure --profile production

Credentials and configuration are stored at ~/.aws/credentials and ~/.aws/config.


Amazon S3 (Simple Storage Service)

# List buckets or contents of a bucket
aws s3 ls
aws s3 ls s3://my-bucket-name/prefix/

# Copy local file to S3
aws s3 cp document.pdf s3://my-bucket-name/docs/

# Sync local directory with S3 bucket (with exclusions)
aws s3 sync ./build s3://my-bucket-name/web --delete --exclude "*.tmp"

# Remove directory/prefix recursively
aws s3 rm s3://my-bucket-name/temporary-files --recursive

Amazon EC2 (Elastic Compute Cloud)

# Describe running instances
aws ec2 describe-instances \
  --filters "Name=instance-state-name,Values=running" \
  --query "Reservations[*].Instances[*].[InstanceId,PublicIpAddress,Tags[?Key=='Name'].Value|[0]]" \
  --output table

# Start / Stop instances
aws ec2 start-instances --instance-ids i-0123456789abcdef0
aws ec2 stop-instances --instance-ids i-0123456789abcdef0

# Terminate instance
aws ec2 terminate-instances --instance-ids i-0123456789abcdef0

Amazon ECS (Elastic Container Service)

# List clusters
aws ecs list-clusters

# Create a cluster
aws ecs create-cluster --cluster-name production-cluster

# List running tasks in cluster
aws ecs list-tasks --cluster production-cluster

AWS Elastic Beanstalk CLI (eb)

# Initialize Elastic Beanstalk application
eb init

# Deploy environment
eb create production-env
eb deploy

# Open application in browser
eb open

# View live application logs
eb logs

Useful Flags & Queries

  • --profile <name>: Execute command under a specific IAM profile.
  • --region <region>: Override configured AWS region (e.g. us-east-1).
  • --output [json|text|table]: Specify CLI output format.
  • --query '<JMESPath>': Filter and extract structured attributes using JMESPath expressions.

Related topics