Getting Started With AWS CLIv2
Tags: aws, awscli, arth, vimaldaga
Published: 2021-03-22 10:59:07

After Reading This Article You will come to know about Basics Of AWS CLI and how to manage AWS Console using AWS CLI.
What Is AWS CLI??

The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

To Learn More about AWS CLI: https://aws.amazon.com/cli/

![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8k537wy9pjd4jwgno699.png)
🎇Installing AWS CLI :

The Installation of AWS CLI is very simple. You just have to download the application compatible with your Operating System from the link provided below and just install it as you install any-other software in your system.

Link: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html 

Once you have installed aws cli in your system open your Terminal or Command Prompt and Run the command mentioned below: 
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x9gxcqm0ols92wnn90qi.png)
Make sure you have Created one user using IAM Service of AWS.

AWS configure:

To authenticate our AWS CLI with our AWS account. For that go to the command line and type the below-mentioned command.

    aws configure

🎇 Next We have to provide your “access key” and “secret key” and then provide region means on which region you want to work on. After That press enter.
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gbssa1y9vazgtyueek8h.png)
🎇 If no error comes up then you are successfully logged in.

🎇Now to run commands in AWS CLI you should have some knowledge of AWS and Its Services. For That The documentation by AWS is best to read and understand. Link: https://docs.aws.amazon.com/cli/index.html Simple way is to use aws help command which will lead us to great insights.

🎇In this article we are going to discuss the below mentioned tasks.

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.

🎇So Let’s Begin…
1) Create a key pair
To create a key pair we need to run the below mentioned command. 
          aws ec2 create-key-pair --key-name KeyName
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i1by6xiiwzzddq12k8wx.png)
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1oggxkutwep4ywhnhv9o.png)
We can also see more options using help , So here our First objective is completed.

2) Create a Security Group
To Create a Security Group We can run below mentioned Command.

    aws ec2 create-security-group --group-name Name --description "DESCRIPTION"
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vrm7rhhuruqwfgcjrns5.png)
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w91sfprnen6u1xmw4x11.png)
Again we can explore more options in this command using help. So here we have created a security Group.

3) Launch an instance using the above created key pair and security group.

Here We have to use The following command. Make sure to confirm the AMI id of particular image of AWS.

    aws ec2 run-instances --image-id ami-0e306788ff2473ccb --instance-type t2.micro --count 1 --subnet-id subnet-a57e77cd --security-group-ids sg-03386457f927715fa --key-name task3key

![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5r5q4nkcbsyjnjnj78ol.png)
Confirming in AWS console.

![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f4r2prw881gtgtucudog.png)
4) Create an EBS volume of 1 GB.

To create an EBS volume of 1GB we have to run the following Command.

    aws ec2 create-volume --volume-type volume type --size 1 --availability-zone Zone

Again here we can also look for more options.    
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wieqkdbi7mgqu2rn3mni.png)
Confirmation in AWS Console.
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uepsr30ocpj9d9y2q0kh.png)
5) The final step is to attach the above created EBS volume to the instance you created in the previous steps.
Type the following command:

    aws ec2 attach-volume --instance-id Instance id --volume-id Volume id --device /dev/sdp  

![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bn3ll8w1d12gkclcl2g.png)
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d0fs3rl9g0odn4ldemi9.png)

🎇These were a few demos of how we can use AWS CLI. Command Line Interface is used by most of the Professionals , Hence to know how to work in cli is very IMPORTANT
I hope you get something new out of it.
Finally😊, Thanks for reading…….