Starting with AWS CLI

Deepanshu Yadav
5 min readOct 14, 2020

let's first see what we are going to do and then we will start doing it:

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

we can do all this from the console of AWS very easily but we are going to do all this from command interface(CLI) of aws to have a new taste of things.

To use aws from our cmd or terminal, we first have to install the aws cli software or we can say we have to install aws command. For this go to below link and download the .msi installer for your respective OS

Now just double click it and do next, next, next and install it simply we do.

Now open your cmd and confirm that you have successfully installed by the command below. it will show as below output if installed

Now you have to configure your cli to your respective account of aws so that any service you try to use using cli it can go to your account and work on it. For this use the command →aws configure

after you type this, give your respective acees key and secret key of your account or user(just copy paste here) and the region you want to work in.

Now we are ready to control all the services of aws from command line. Let’s start our task now.

Strategy how to use CLI:

To do anything in cli you first have to type aws and then the service you want to use. if you don’t know what can you do further at anytime, just type help and you will find documentary of everything of it you can do next. This helps a lot. if you dont know what to write after aws then type aws help. see that you have now got all the services name of aws. use spacebar to go to next page of doc and enter to move to next line.

eg- if you want to use ec2 services then type aws ec2 and then just type help to see the further options you can have.

use tab to see the infinite things you can do in ec2 and these detailed things you can’t find from console. so this helps to learn a service in more detail in fact you can get every bit of it. Further you can type any option and after it type help to see how it works.

Now let’s start what we were going to do i.e. our task.

  1. To create a key pair use the below command(i had found the command from the above mentioned way). The command in first ss will also save your key in a notepad file(this i have done json parsing,you can’t find it from help). you can also use simply the command in 2nd ss to create key pair.

2. Now you can create the security group from the below command. you can set your rules accordingly, i have gone with the default. just use the help to create rules.

3. similarly, create the EBS volume from the command below.

Now we can launch the OS with the below command. step by step you can use the help command to see what and how the specifications we want to give. First go to console and write the steps what we have given to os like subnet, SG, etc and then do the same from cli using help command. The final command you need to launch an OS is shown below. here i have give IDs of SG, subnet, etc of mine. you have to give of your own otherwise it won’t work.

NOTE- you won’t see the error-output type none instead you will find the details of your instance you have launched. (its coming in mine because i changed the output during configuration during some testing)

Now the final step is to attach the EBS volume we have created already to the instance we launched just now, do as below

so, we are done finally, you can see from your console that an instance has been created and an EBS volume also of size 1gb which is attached to this instance. or you can see the same from the cli also by the command aws ec2 describe-instances — instance-ids yourinstanceid.

--

--