Skip to main content

Command Palette

Search for a command to run...

Day - 9 | aWS CLI

Published
โ€ข3 min readโ€ขView as Markdown

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

FeatureAWS CLIAWS Console
AutomationYesNo
SpeedFastSlower
ScriptingSupportedNot supported
Beginner FriendlyMediumHigh

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

More from this blog

Bipul Kumar

45 posts