Whether you’re managing cloud infrastructure, deploying applications, or automating tasks, the AWS Command Line Interface (CLI) is an essential tool in every engineerโs toolkit. This cheat sheet provides a concise yet powerful collection of commonly used AWS CLI commands across core services โ perfect for quick reference and daily operations.
๐ฆ Getting Started
Before using the CLI, install and configure:
# Install AWS CLI v2 (Linux/macOS) curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip && sudo ./aws/install # Configure CLI aws configure
You’ll be prompted to enter:
-
Access Key ID
-
Secret Access Key
-
Default Region (e.g.,
us-east-1) -
Default Output Format (
json,table, ortext)
๐ Identity & Access Management (IAM)
# List users aws iam list-users # Create a new user aws iam create-user --user-name <username> # Attach policy to a user aws iam attach-user-policy \ --user-name <username> \ --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess
๐๏ธ S3 (Simple Storage Service)
# List buckets aws s3 ls # Create a bucket aws s3 mb s3://my-bucket-name # Upload file aws s3 cp myfile.txt s3://my-bucket-name/ # Download file aws s3 cp s3://my-bucket-name/myfile.txt . # Sync local dir to S3 aws s3 sync ./mydir s3://my-bucket-name/ # Delete file aws s3 rm s3://my-bucket-name/myfile.txt
โ๏ธ EC2 (Elastic Compute Cloud)
# List EC2 instances aws ec2 describe-instances # Launch EC2 instance aws ec2 run-instances \ --image-id ami-0abcdef1234567890 \ --count 1 \ --instance-type t2.micro \ --key-name my-key-pair \ --security-groups my-security-group # Stop instance aws ec2 stop-instances --instance-ids i-0123456789abcdef0 # Start instance aws ec2 start-instances --instance-ids i-0123456789abcdef0 # Terminate instance aws ec2 terminate-instances --instance-ids i-0123456789abcdef0
๐ CloudWatch
# List metrics aws cloudwatch list-metrics # Get metric data aws cloudwatch get-metric-data \ --metric-data-queries file://queries.json \ --start-time 2025-07-10T00:00:00Z \ --end-time 2025-07-11T00:00:00Z
๐๏ธ CloudFormation
# Deploy a stack aws cloudformation deploy \ --template-file template.yaml \ --stack-name my-stack \ --capabilities CAPABILITY_NAMED_IAM # Delete a stack aws cloudformation delete-stack --stack-name my-stack
๐ณ ECS (Elastic Container Service)
# List clusters aws ecs list-clusters # List services in a cluster aws ecs list-services --cluster my-cluster # Describe a service aws ecs describe-services \ --cluster my-cluster \ --services my-service # Update a service (force new deployment) aws ecs update-service \ --cluster my-cluster \ --service my-service \ --force-new-deployment
๐ก๏ธ Security Groups & Networking
# List security groups aws ec2 describe-security-groups # Authorize ingress rule aws ec2 authorize-security-group-ingress \ --group-id sg-12345678 \ --protocol tcp \ --port 22 \ --cidr 0.0.0.0/0
๐ Secrets Manager
# List secrets aws secretsmanager list-secrets # Get secret value aws secretsmanager get-secret-value \ --secret-id my-secret
๐ Useful Flags & Tips
-
--region <region>โ override default region -
--profile <profile>โ use a specific profile -
--queryโ filter results using JMESPath -
--output tableโ human-readable format
Example:
aws ec2 describe-instances --query "Reservations[*].Instances[*].InstanceId" --output text
๐ Resources
โ Conclusion
The AWS CLI is a powerful tool that can dramatically speed up your workflow and enable automation. Keep this cheat sheet handy for quick access to the most commonly used commands โ and don’t be afraid to explore further with the aws help command.