AWS CLI BASICS
Hey, guys hope you all are doing good in today's article we are going to see what is Aws CLI, how to use Aws CLI, What's the need of Aws CLI.
Let's start with the first Question Why we need Aws CLI?
Suppose you are a cloud engineer and have to process similar task again and again but in today's would its not a good approach that we do the same things again and again manually goos approach is to make scripts to automate the things and if we want scripts to automate the things then they should be run and they run respective command what we feed in them and that command should be recognized by our system for that we need CLI software of product. It's just one example of why we need Cli there are many more benefits of using CLI.
Now the Next question What is Aws CLI?
As the name suggests AWS CLI means amazon command-line interface which allows you to monitor and control all AWS services from the local terminal of your system.
How to use Aws CLI?
It's pretty easy to install Aws CLI just go to the below website download software for your respective system and just install it by clicking next you will not face any complication in this is very easy but still, if you face any issue you can contact me I will always there for you to help.
Once you install CLI to check it on your system type “aws --version” if the output comes as shown below then we are all set and we are good to go.
Now once aws cli is set go to your Aws root account and go to IAM user and create one IAM user if you don’t know how to make a new IAM follow the below steps.
Step1 Sign in with root account and select IAM service
Step2 Inside IAM service select user option and click on add user and fill the field as shown below
Step3 Once done download the CSV file as shown below it contain access key and secret key we need to configure in aws cli.
Once all the above steps are done we are all set to go to configure aws cli
Step4 In the command prompt type “aws configure” when you type this you will see the output like enter access key secret key and all these details can be found in the CSV file we downloaded while creating IAM user.
Once all this done we can now we can easily manage our aws service from our command prompt for testing we create one keypair, one security group, one ebs volume of 10gb, and one instance with attaching the following parameters all this we are going to do with CLI.
First, let's create our Key pair and save it to our system
Execute the following command to create a new key pair and save it to your system.
aws create-key-pair --key-name your_key_name --query keyMaterial > your_key_name.pem
Execute the following command to create a new Security Group.
aws ec2 create-security-group --group-name name_youwant_to_give --description "description you want to give"
To get detail of your security group execute the following command.
aws ec2 describe-security-groups --groups-names nameof yourgrp
To set the security ingress rule of your security group execute the following command.
aws ec2 authorize-security-group-ingress --group-id security_group_id --protocol protocolname --port portno --cidr cidrblockvalue
Once the key pair and security group is made then we can move toward launching our instance by attaching the key pair and security group we made. Execute the following command to launch the instance.
aws ec2 run-instances --security-group-ids sggroupid --instance-type instance type(egt2micro) --image-id ami id --key-name key name --count no of instance you want to launch --subnet-id subnetid
To launch Ebs use the following command
aws ec2 create volume --volume-type type you want (eg gp2) --size sizeyouwant --availablity-zone zoneinwhichyouwanttolaunch
To attach Ebs volume to your instance you launched use the following command
aws ec2 attach-volume --volume-id yourvolumeid --instance-id yourinstanceid --device devicename
To detach the volume execute the following command
aws ec2 detach-volume --volume-id volumid
To terminate the instance execute the following command
aws ec2 terminate-instances --instance-ids instanceid
Guys, here we come to the end of this blog I hope you all like it and found it informative.
Guys follow me for such amazing blogs and if have any review then please let me know I will keep those points in my mind next time while writing blogs. If want to read more such blog to know more about me here is my website link https://sites.google.com/view/adityvgupta/home.Guys Please do not hesitate to keep 👏👏👏👏👏 for it (An Open Secret: You can clap up to 50 times for a post, and the best part is, it wouldn’t cost you anything), also feel free to share it across. This really means a lot to me.