Day - 9 | aWS CLI
Getting Started with AWS CLI (Command Line Interface)
As part of my cloud learning journey, I recently explored the AWS Command Line Interface (AWS CLI). AWS CLI is a powerful tool that allows us to interact with AWS services directly from the terminal, making cloud operations faster, repeatable, and automation-friendly.
In this blog, Iโll share my understanding of AWS CLI, how to set it up, and how it helps in real-world cloud and DevOps workflows.
๐ What is AWS CLI?
AWS CLI is a unified command-line tool provided by Amazon Web Services that enables users to manage AWS services using commands instead of the AWS Management Console.
With AWS CLI, you can:
Create and manage AWS resources
Automate repetitive cloud tasks
Integrate AWS operations into scripts and CI/CD pipelines
It is widely used by Cloud Engineers, DevOps Engineers, and SREs.
๐งฉ Why Use AWS CLI?
Some key benefits of AWS CLI include:
Automation โ Execute repetitive tasks using scripts
Speed โ Faster than navigating the AWS Console
Consistency โ Same commands across environments
Integration โ Works well with shell scripts and CI/CD tools
๐ ๏ธ Installing AWS CLI
๐น On Linux / Ubuntu
sudo apt update
sudo apt install awscli -y
๐น On Windows
Download the AWS CLI MSI installer from the AWS official website
Complete the installation wizard
Verify installation:
aws --version
๐ Configuring AWS CLI
Before using AWS CLI, it must be configured with AWS credentials.
aws configure
You will be prompted to enter:
AWS Access Key ID
AWS Secret Access Key
Default region name (e.g., us-east-1)
Default output format (json)
These credentials are stored securely in the local system.
๐ฆ Basic AWS CLI Commands
๐น List S3 Buckets
aws s3 ls
๐น Upload File to S3
aws s3 cp file.txt s3://bucket-name/
๐น Download File from S3
aws s3 cp s3://bucket-name/file.txt ./
Create EC2
aws ec2 run-instances \
--image-id ami-0ecb62995f68bb549 \
--instance-type t3.micro \
--key-name monukey \
--security-group-ids sg-0e36b8cde65590a72 \
--subnet-id subnet-09c4fc6e15071b5ac \
--associate-public-ip-address \
--region us-east-1 \
--count 1 \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=EC2-CLI-Demo}]'
List EC2 Instances
aws ec2 describe-instances
๐น List IAM Users
aws iam list-users
๐ AWS CLI vs AWS Console
| Feature | AWS CLI | AWS Console |
| Automation | Yes | No |
| Speed | Fast | Slower |
| Scripting | Supported | Not supported |
| Beginner Friendly | Medium | High |
Both are useful, but AWS CLI is preferred for automation and large-scale operations.
๐ง Real-World Use Cases
Automating EC2 start/stop operations
Uploading application logs to S3
Managing infrastructure in CI/CD pipelines
Performing bulk operations across AWS services
๐ Security Best Practices
Never expose AWS credentials publicly
Use IAM Roles instead of access keys on EC2
Grant least privilege permissions
Rotate access keys regularly