AWS CLI Cheatsheet

AWS CLI commands for S3, EC2, Lambda, IAM, ECS, CloudFormation, and more

The AWS CLI cheatsheet covers the most-used AWS CLI commands for S3, EC2, Lambda, IAM, ECS/ECR, CloudFormation, and CloudWatch. Search by service or command and copy any example with one click.

How to Use This AWS CLI Cheatsheet

The AWS CLI lets you manage AWS services from the command line. Install it with the official installer, then run aws configure to set up your credentials and default region.

Output Formats

AWS CLI supports three output formats: json (default), table (human-readable), and text (scriptable). Set per-command with --output table or change the default with aws configure.

Filtering with --query

Use JMESPath with --query to extract specific fields: aws ec2 describe-instances --query 'Reservations[*].Instances[*].InstanceId' --output text. This avoids parsing large JSON responses in scripts.

Multiple Profiles

Use --profile name or set AWS_PROFILE=name to switch between accounts without changing credentials.

Frequently Asked Questions

Is this AWS CLI cheatsheet free?

Yes, completely free with no signup. All commands shown with examples and copy buttons.

How do I configure AWS CLI credentials?

Run aws configure to set your Access Key ID, Secret Access Key, default region, and output format. Credentials are stored in ~/.aws/credentials. For multiple accounts use aws configure --profile myprofile and add --profile myprofile to commands. In CI/CD set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.

What is the difference between aws s3 and aws s3api?

aws s3 provides high-level commands (cp, sync, mv, ls) that are simpler for common tasks. aws s3api provides low-level API access for advanced operations like ACLs, versioning, and lifecycle rules. Use aws s3 for day-to-day tasks, aws s3api when you need fine-grained control.

How do I filter AWS CLI output?

Use --query with JMESPath expressions to filter JSON output: aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,State.Name]'. Use --output table for human-readable tables, --output text for scripting. Pipe to jq for complex processing: aws s3api list-buckets | jq '.Buckets[].Name'.

How do I use AWS CLI profiles for multiple accounts?

Create profiles with aws configure --profile work. Use them with --profile work on any command, or set AWS_PROFILE=work environment variable for a session. List configured profiles with aws configure list-profiles. Switch between accounts without re-entering credentials.