AWS CLI Cheatsheet - Cloud Commands

All essential AWS CLI commands organized by use case, with 41+ entries you can copy and run directly. Find the right command fast when you need it.

SysOps·41 commands·Last updated 2026-07-19
Back to SysOps

Configure & Auth 6

aws configure
Interactive configure access key and region
aws configure --profile production
Configure credentials for a profile
aws configure list
Show current config
aws sts get-caller-identity
Verify the current identity
export AWS_PROFILE=production
Switch the default profile
aws configure set region us-west-2
Set a single config value

EC2 Instances 6

aws ec2 describe-instances --filters "Name=instance-state-name,Values=running"
List running instances
aws ec2 describe-instances --query "Reservations[].Instances[].[InstanceId,State.Name]"
Query instance IDs and state
aws ec2 start-instances --instance-ids i-xxxxx
Start an instance
aws ec2 stop-instances --instance-ids i-xxxxx
Stop an instance
aws ec2 terminate-instances --instance-ids i-xxxxx
Terminate an instance (irreversible)
aws ec2 create-key-pair --key-name my-key --query "KeyMaterial" --output text > my-key.pem
Create an SSH key pair, save the private key

S3 Storage 8

aws s3 ls
List all buckets
aws s3 ls s3://my-bucket/
List bucket contents
aws s3 cp file.txt s3://my-bucket/
Upload a file
aws s3 cp s3://my-bucket/file.txt ./file.txt
Download a file
aws s3 sync ./local/ s3://my-bucket/remote/
Sync a directory (changed files only)
aws s3 sync s3://src-bucket/ s3://dst-bucket/ --delete
Sync buckets and delete extras
aws s3 rm s3://my-bucket/file.txt
Delete a file
aws s3 mb s3://new-bucket-name
Create a new bucket

IAM Users & Policies 6

aws iam list-users
List all IAM users
aws iam create-user --user-name newuser
Create an IAM user
aws iam create-access-key --user-name newuser
Create an access key for a user
aws iam attach-user-policy --user-name newuser --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
Attach a managed policy to a user
aws iam list-attached-user-policies --user-name newuser
List a user's attached policies
aws iam delete-user --user-name newuser
Delete an IAM user

CloudWatch Logs 5

aws logs describe-log-groups
List log groups
aws logs tail /app/production --follow
Tail logs in real time
aws logs filter-log-events --log-group-name mygroup --start-time 1234567890
Filter logs by time
aws logs tail /app/production --since 1h
Show logs from the last hour
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --start-time 2026-07-20T00:00:00Z --end-time 2026-07-21T00:00:00Z --period 3600 --statistics Average
Query EC2 CPU utilization metric

Lambda & Services 5

aws lambda list-functions
List all Lambda functions
aws lambda invoke --function-name my-function output.json
Invoke a Lambda function (sync)
aws lambda create-function --function-name my-fn --runtime python3.11 --role arn:aws:iam::123:role/role --handler index.handler --zip-file fileb://fn.zip
Create a Lambda function
aws rds describe-db-instances
List RDS DB instances
aws dynamodb list-tables
List DynamoDB tables

Query Tips 5

aws ec2 describe-instances --output table
Output as a table (readable)
aws s3api list-objects --bucket my-bucket --query "Contents[?Size>`1000000`].Key"
JMESPath query for files > 1MB
aws ec2 describe-instances --filters "Name=tag:Name,Values=web-*"
Filter instances by tag
aws ec2 describe-instances --query "Reservations[].Instances[].PublicIpAddress" --output text
Extract all instances' public IPs
aws s3 presign s3://my-bucket/file.zip --expires-in 3600
Generate a 1-hour presigned URL

Tips

  • aws configure --profile creates named profiles for multi-account use.
  • S3 sync transfers only changed files - good for backup/deploy.
  • describe-instances --query filters output with JMESPath.
  • Logs Insights queries are more powerful than filter-log-events.
  • --output json/table/text: text for scripts, table for humans.
  • --query with JMESPath + --output text suits shell scripts.

Official References

Commands are compiled from the official docs below. Click to verify the latest usage.

Maintained by LaoHand

Publicly updated on Jul 19, 2026, continuously proofread against official docs.

Contact Us

Wrong command or description? Send us corrections, business inquiries or product feedback by email.

Contact Us