โImagine controlling all of AWS with just your keyboard.โ
No endless clicking, no hunting through console tabs โ just raw power, in your terminal.
Welcome to the AWS CLI (Command Line Interface) โ your cloud command center. In this guide, weโll unlock its full potential with real-world examples, beginner-friendly tips, and the exact commands to get you automating like a DevOps pro.
๐ค What Is the AWS CLI?
The AWS Command Line Interface lets you interact with AWS services using simple commands from your terminal.
Itโs like talking directly to AWS without using the browser.
Real-world analogy: Think of the AWS Console as the iPhone app โ nice UI. But AWS CLI is like using Siri for superpowers. Fast, precise, and fully scriptable.
๐ง Step 1: Install and Configure AWS CLI
โ Install AWS CLI (v2 recommended)
- On Mac:
brew install awscli
- On Ubuntu:
sudo apt install awscli -y
- On Windows: Use the installer
โ Configure It
Youโll need your AWS access keys:
aws configure
Youโll be prompted to enter:
- AWS Access Key ID
- AWS Secret Access Key
- Default region (e.g.,
us-east-1) - Output format (choose
jsonortablefor readability)
Done? Youโre ready to fly. ๐
โก Real-World AWS CLI Commands Youโll Use Daily
๐ Check Your Identity
aws sts get-caller-identity
Great for validating your current credentials.
๐พ S3: Upload & Download Files
aws s3 cp mysite/index.html s3://my-bucket-name/
aws s3 sync ./website s3://my-bucket-name/
๐
syncis your best friend for automated static site updates.
๐ป EC2: Start, Stop, and Manage Instances
aws ec2 describe-instances
aws ec2 start-instances --instance-ids i-1234567890abcdef0
aws ec2 stop-instances --instance-ids i-1234567890abcdef0
โ๏ธ RDS: Check Database Status
aws rds describe-db-instances
๐ฆ Deploy a Lambda Function
aws lambda create-function \
--function-name my-function \
--runtime nodejs18.x \
--handler index.handler \
--role arn:aws:iam::123456789012:role/my-lambda-role \
--zip-file fileb://function.zip
๐ก Pro Tip: Combine these with shell scripts or GitHub Actions to automate CI/CD pipelines!
๐ Automate Like a Pro: Shell Scripts + AWS CLI
Hereโs an example script to stop all EC2 instances in a specific region:
#!/bin/bash
for id in $(aws ec2 describe-instances \
--query "Reservations[*].Instances[*].InstanceId" \
--output text); do
echo "Stopping instance $id..."
aws ec2 stop-instances --instance-ids $id
done
This is how you go from manual admin to DevOps automation master.
๐ง Why Learn AWS CLI?
| Benefit | Why It Matters |
|---|---|
| ๐ Speed | One command > 10 clicks |
| ๐ Automation | Script repeatable tasks |
| ๐ฆ CI/CD | Perfect for DevOps pipelines |
| ๐งช Scripting | Combine with Bash, Python, or cron jobs |
| ๐ค API Control | Under the hood of all AWS SDKs |
๐ก Security Tips
- Never hard-code credentials in scripts
- Use IAM roles with
aws sts assume-role - Rotate access keys regularly
- Use AWS profiles for multi-account setups:
aws configure --profile dev
๐งช Try These Challenges
- โ Upload your portfolio to S3 using the CLI
- โ Write a script to back up logs to S3 every day
- โ Start and stop EC2 based on time of day (cron + CLI)
- โ Describe all Lambda functions in your region
Want the step-by-step for any of these? Just ask in the comments!
๐ฌ Join the CLI Movement!
The AWS CLI isnโt just a tool โ itโs a superpower. Once you master it, you'll never want to go back to the web console again.
๐ Whatโs your favorite AWS CLI trick? Got a script that changed your workflow?
Drop it in the comments, smash โค๏ธ if you learned something new, and share this with your terminal-loving friends!
Letโs automate the cloud โ one command at a time. ๐งก
Top comments (0)