
Getting Started with AWS CLI in Windows

What is AWS CLI?
AWS Command Line Interface(AWS CLI) is a unified tool using which you can manage and monitor all your AWS services from a terminal session on your client.
Why AWS CLI?
Easy Installation: The installation of AWS Command Line Interface is quick, simple and standardized.
Saves Time: You need not log on to your account again and again for checking or updating the current status of services. Thus it saves time a lot
Automates Processes: AWS CLI gives you the ability to automate the entire process of controlling and managing AWS services through scripts. These scripts make it easy for users to fully automate cloud infrastructure.
Supports all Amazon Web Services: Prior to AWS CLI, users needed a dedicated CLI tool for just the EC2 service. But now AWS CLI lets you control all the services from one simple tool.
Objectives
- Create a key pair.
- Create a security group & its rules
- Launch an instance using the above created key pair and security group.
- Create an EBS volume of 1 GB.
- The final step is to attach the above created EBS volume to the instance you created in the previous steps.
Pre-requisites
- AWS CLI should be installed in your system
- AWS IAM account with Administrator Access
Creation of Key-Pair:
A key pair, consisting of a private key and a public key, is a set of security credentials that you use to prove your identity when connecting to an instance. It is essential to launch an instance.
aws ec2 create-key-pair --key-name MyKeyPair

We can also verify this in AWS Management Console which is shown in below figure.

Creation of Security Group:
A security group acts as a virtual firewall for your instance to control inbound and outbound traffic. When you launch an instance in a VPC, you can assign up to five security groups to the instance.
Security groups act at the instance level, not the subnet level. Therefore, each instance in a subnet in your VPC can be assigned to a different set of security groups.
aws ec2 create-security-group — group-name MySecurityGroup — description “My security group”

There are two types of traffics namely Inbound or Ingress and Outbound or Egress traffic. We have to frame the rules for these traffics. You can choose a common protocol, such as SSH (for a Linux instance), RDP (for a Windows instance), and HTTP and HTTPS to allow Internet traffic to reach your instance. You can also manually enter a custom port or port ranges.
Inbound traffic:
To allow inbound traffic entered to your instance, you have to create ingress rules. In this ssh and HTTP protocols are allowed by creating rules for them because our instance is mostly accessed by these types of protocols only by the clients.
HTTP
aws ec2 authorize-security-group-ingress --group-id sg-02658f46b1c47c775 --protocol tcp --port 80 --cidr 0.0.0.0/24
SSH
aws ec2 authorize-security-group-ingress --group-id sg-02658f46b1c47c775 --protocol tcp --port 22 --cidr 0.0.0.0/24

Outbound traffic:
To allow outbound traffic entered to your instance, you have to create egress rules. Normally, we can allow all protocols and ports so that our instance can have full outside accessibility.
aws ec2 authorize-security-group-egress --group-id sg-02658f46b1c47c775 --protocol all --cidr 0.0.0.0/24

Creation of EC2 instances:
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers. For create an instance, two things required namely KeyPair and SecurityGroups which we already created in the previous steps.
aws ec2 run-instances --security-group-ids sg-02658f46b1c47c775 --tag-specifications ResourceType=instance,Tags=[{Key=Name,Value=RHEL8_OS}] --image-id ami-0a9d27a9f4f5c0efc --instance-type t2.micro --key-name MyKeyPair

Creation of EBS Volume:
Amazon Elastic Block Store (EBS) is an easy to use, high-performance block storage service designed for use with Amazon Elastic Compute Cloud (EC2) for both throughput and transaction-intensive workloads at any scale. It provides extra storage space to an instance. Scripts to create an EBS volume using AWS CLI is given below.
aws ec2 create-volume --size 1 --tag-specifications ResourceType=volume,Tags=[{Key=Name,Value=MyEbs}] --availability-zone ap-south-1aOutput:

Attaching EBS Volume to an EC2-instance:
When the storage in EC2-instance is going to fully utilized, the extra EBS volume is required to store further data. For this, we have to create and attach EBS volume to an EC2-instance. For this, we have to specify the instance id and security group in the following command.
aws ec2 attach-volume --volume-id vol-069d5e139cecca623 --instance-id i-0cff77d67530f8bdd --device /dev/sdc

Finally our objective is successfully executed. This is only the start of AWS CLI, further the more to come in future. Feel free to express your views through feedbacks and if you have any doubts and need clarifications, you can contact me through linkedin
Written by
Sri Vishnuvardhan
Building production-grade geospatial platforms that combine GIS, remote sensing, cloud infrastructure, AI, and platform engineering to transform spatial data into scalable, real-world intelligence.
Enjoyed this article?
Subscribe to get notified when new articles on DevOps, Cloud, and platform engineering are published.
You'll receive a welcome email with a confirmation link. No spam — unsubscribe anytime.
Have a project in mind?
I work on cloud-native platforms, DevOps automation, and geospatial intelligence systems. Let's talk.