Introduction
The AWS CLI is the official command-line tool from Amazon for interacting with AWS services. It provides direct access to every public API across all AWS services, enabling developers and operators to script infrastructure tasks, automate deployments, and manage cloud resources without leaving the terminal.
What AWS CLI Does
- Provides unified access to all AWS service APIs from a single command-line tool
- Supports output in JSON, YAML, text, and table formats for easy scripting and readability
- Manages named profiles and credential chains for multi-account workflows
- Enables high-level commands like
aws s3 syncfor common operations beyond raw API calls - Supports server-side and client-side filtering with
--queryusing JMESPath expressions
Architecture Overview
AWS CLI v2 is a Python application distributed as a standalone installer or via pip. It uses botocore as the underlying SDK layer to sign requests with SigV4, handle retries, and paginate results. Service models are auto-generated from AWS service definitions, ensuring new APIs are available shortly after launch. Configuration is stored in ~/.aws/config and ~/.aws/credentials.
Self-Hosting & Configuration
- Install via standalone installer for Linux, macOS, or Windows without needing Python
- Alternatively install with pip:
pip install awscli - Run
aws configureto set up access key, secret key, default region, and output format - Use named profiles with
aws configure --profile stagingfor multi-account setups - Set
AWS_PROFILEor--profileflag to switch between environments
Key Features
- Covers every AWS service and API action with consistent syntax
- Supports SSO login via
aws sso loginfor enterprise identity providers - Provides waiters that poll until a resource reaches a desired state
- Offers skeleton generation with
--generate-cli-skeletonfor complex input shapes - Autocomplete plugin available for bash and zsh shells
Comparison with Similar Tools
- AWS Console — graphical web UI; AWS CLI is faster for bulk operations and scriptable
- AWS SDK (boto3) — full Python library; AWS CLI wraps it for one-off shell commands
- AWS CloudShell — browser-based shell with CLI pre-installed; local CLI works offline
- Terraform/Pulumi — declarative IaC; AWS CLI is imperative and useful for ad-hoc tasks
- Azure CLI / gcloud — equivalent tools for other clouds; AWS CLI is AWS-specific
FAQ
Q: What is the difference between AWS CLI v1 and v2? A: v2 is the current version with SSO support, auto-prompt, and a standalone installer. v1 is legacy and requires Python.
Q: Can I use AWS CLI with temporary credentials? A: Yes. It supports STS assume-role, SSO, and environment variable-based session tokens.
Q: How do I filter output?
A: Use --query with JMESPath expressions or --output text for tab-separated values suitable for piping.
Q: Does AWS CLI support pagination automatically?
A: Yes. Most list commands auto-paginate by default. Use --no-paginate to disable.