How to Set-up AWS CLI on Windows? How can Provision AWS Resources Through AWS CLI?

Rahul Kumar
5 min readDec 1, 2020


In this blog, I'm going to discuss about AWS CLI, how we can use AWS CLI? How can We launch ec2 instance with AWS CLI?

Content of this Blog:

🔅What is AWS CLI?

🔅 Set-up AWS CLI on windows then Task Which we are performing Through AWS CLI: -

🔅Create a key pair

🔅 Create a security group

🔅 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.

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

Ways to Access AWS resources: -

There are many ways to access Aws: -

  1. By using GUI (Graphical User Interface)
  2. By Automation
  3. By AWS CLI (command line Interface)

and more...


To performing the task through AWS CLI, we need AWS account and a IAM user.

What are AWS CLI?

  • To save time when making API requests, you can use the AWS Command Line Interface (AWS CLI). AWS CLI enables you to control multiple AWS services directly from the command line within one tool. AWS CLI is available for users on Windows, macOS, and Linux.
  • By using AWS CLI, you can automate the actions that your services and applications perform through scripts. For example, you can use commands to launch an Amazon EC2 instance, connect an Amazon EC2 instance to a specific Auto Scaling group, and more.

Configure/Setting up AWS CLI: -

You can install the tool by downloading it from the AWS CLI resource page at Amazon.

After the installation To Check whether it is installed or not by command “aws --version”: -

To using AWS CLI, we need to create an Identity and Access Management (IAM).

To Create an IAM User: -

There are some steps required to create an IAM User: -


Go to Service and in “Security, identity & Compliances” section Click on IAM.


Click on users in IAM resources.


Now click on Add user


Now give the username and tick on Programmatic access in Access Type To use AWS API, CLI, SDK and other development tools.


Now, Set/Attach a permission for IAM user. In my case, I am giving “PowerUserAccess”, In “PowerUserAccess” user can do everything except checking billing dashboard and creating a new user.


See your user created, now download .CSV file and you will get an access key ID and secret access key for users sign up for an AWS account.

To Sign Up an AWS account by AWS CLI: -

We need an Access key ID and Secret access key for sign up to AWS account. We use “aws configure” command for Signing up for an AWS account by AWS CLI.

Now, we can perform the task.

Provision AWS Resources Using AWS CLI:

Task No 1. Creating a key pair Using AWS CLI:

For creating a key pair by using command “aws ec2 create-key-pair --key-name keypairname”

In my case, key pair name is “MyNewKeyPair”.

By Using GUI, You can see a key pair created named “MyNewKeyPair”.:

2. Creating a Security Group Using AWS CLI :

To create Security group by using command ‘ aws ec2 create-security-group --group-name MySecurityGroup --description “My security group”’

By Using GUI, you can see a security Group created:

3. Launching an instance using the above created key pair and security group: -

To launch Ec2 Instance by CLI (Command Line Interface) by using command:

“ aws ec2 run-instances --image-id ami-0e306788ff2473ccb --instance-type t2.micro --count 1 --subnet-id subnet-a1979ec9--security-group-ids sg-02ed8533400948834 --key-name MyNewKeyPair --tag-specifications ResourceType=instance,Tags=[{Key=Name,Value=OS}] ”

By Using GUI, you can see an ec2 instance created named OS:

4. Creating an EBS volume of 1 GB.

for creating EBS volume by cli use command:

“ aws ec2 create-volume --availability-zone ap-south-1a --size 1” .

By using GUI see a 1 GB volume added.

5. To attaching the above created EBS volume to the previously created instance:

For attaching the EBS volume to ec2 instance (OS) by command:

“aws ec2 attach-volume — volume-id vol-04aba5c673ec9e464 — instance-id i-08011740560fafdf — device /dev/sdf ”

To check the volume is attached or not by using a command “fdisk -l”:

See, there is a 1GB volume is added to Ec2 instance.