The AWS Command Line Interface (AWS CLI) is one of the most powerful tools in a developer’s workflow. Whether you’re managing infrastructure, deploying applications, or automating cloud operations, the AWS CLI provides direct access to AWS services from your terminal.
For developers working with DevOps, backend systems, cloud-native applications, or automation pipelines, mastering the AWS CLI is essential.
This article covers the most commonly used AWS CLI commands and practical examples for real-world usage.
Why Use AWS CLI?
While the AWS Console is user-friendly, the CLI offers:
- Faster workflows
- Automation capabilities
- Scriptable deployments
- CI/CD integration
- Infrastructure management at scale
For serious cloud work, CLI proficiency separates beginners from professionals.
1. Authentication & Configuration
Before using AWS CLI, you must configure your credentials.
Configure AWS Credentials
aws configure
You’ll be prompted for:
- AWS Access Key ID
- AWS Secret Access Key
- Default region
- Output format (json/table/text)
Verify Current Identity
aws sts get-caller-identity
This is one of the most useful debugging commands. It tells you exactly which IAM user or role you’re authenticated as.
2. S3 Commands (Most Frequently Used)
Amazon S3 is one of the most widely used AWS services.
List All Buckets
aws s3 ls
List Objects in a Bucket
aws s3 ls s3://my-bucket
Upload a File
aws s3 cp file.txt s3://my-bucket/
Upload a Folder Recursively
aws s3 cp my-folder s3://my-bucket/ --recursive
Sync Local Folder with S3
aws s3 sync ./local-folder s3://my-bucket
The sync command is especially powerful for deployments and backups.
3. EC2 Commands
Managing virtual servers through CLI is extremely efficient.
List EC2 Instances
aws ec2 describe-instances
Start an Instance
aws ec2 start-instances --instance-ids i-1234567890abcdef0
Stop an Instance
aws ec2 stop-instances --instance-ids i-1234567890abcdef0
These are commonly used in automation scripts.
4. Lambda Commands
Serverless development often relies heavily on CLI operations.
List Lambda Functions
aws lambda list-functions
Invoke a Function
aws lambda invoke \ --function-name my-function \ output.json
Update Function Code
aws lambda update-function-code \ --function-name my-function \ --zip-file fileb://function.zip
This is essential for CI/CD pipelines.
5. IAM Commands
Identity and Access Management controls permissions in AWS.
List IAM Users
aws iam list-users
List IAM Roles
aws iam list-roles
Understanding IAM via CLI is critical for security-focused teams.
6. RDS Commands
For database management:
List RDS Instances
aws rds describe-db-instances
This helps monitor production databases programmatically.
7. Output Formatting & Querying (Advanced)
AWS CLI becomes powerful when combined with filtering.
Output as Table
aws ec2 describe-instances --output table
Query Specific Data
aws ec2 describe-instances \ --query "Reservations[*].Instances[*].InstanceId"
This uses JMESPath filtering and is extremely useful in automation.
