DEV Community

Yash Sonawane
Yash Sonawane

Posted on

AWS CLI in Action: Automate Everything From Your Terminal โšก๐Ÿ–ฅ๏ธ

โ€œ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
Enter fullscreen mode Exit fullscreen mode
  • On Ubuntu:
sudo apt install awscli -y
Enter fullscreen mode Exit fullscreen mode

โœ… Configure It

Youโ€™ll need your AWS access keys:

aws configure
Enter fullscreen mode Exit fullscreen mode

Youโ€™ll be prompted to enter:

  • AWS Access Key ID
  • AWS Secret Access Key
  • Default region (e.g., us-east-1)
  • Output format (choose json or table for readability)

Done? Youโ€™re ready to fly. ๐Ÿš€


โšก Real-World AWS CLI Commands Youโ€™ll Use Daily

๐Ÿ” Check Your Identity

aws sts get-caller-identity
Enter fullscreen mode Exit fullscreen mode

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/
Enter fullscreen mode Exit fullscreen mode

๐Ÿ” sync is 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
Enter fullscreen mode Exit fullscreen mode

โ˜๏ธ RDS: Check Database Status

aws rds describe-db-instances
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“ฆ 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
Enter fullscreen mode Exit fullscreen mode

๐Ÿ’ก 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

๐Ÿงช 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)