Amazon Web Services using CLI

- Three ways to communicate with AWS services/tools are :
=> WEB-UI/APP
=>Automation
=>CLI
- We are going to use here AWS using CLI.
- AWS-CLI is command line interface for that we need a software amazon-CLIV2

- To login into AWS-CLI we need a access key as user-id and a secret key as password.
- The default format of AWS-CLI output is JSON.
- We can use #aws help to get all the commands of CLI.
TASK DESCRIPTION :
🔅 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.
Step 1 : Creating a new key pair
#aws ec2 create-key-pair — key-name myawskey

Now you can check through WEB-UI key is successfully created.

Step 2 : Creating a security group
#aws ec2 create-security group — group-name aws-security-group — description aws-sg

Now the security group is successfully created.

Step 3 : To launch an instance using the above created key pair and security group.
#aws ec2 run-instances — image-id ami-0e306788ff2473ccb — count 1 — instance-type t2.micro — key-name myawskey — security-group-ids sg-01af9ffe6dcbcf8a5 — subnet-id subnet-a9959dc1

Now our new instance is successfully launched using myawskey and aws-security-group it is running in aws portal.

Step 4 : To create an EBS volume of 1 GB.
#aws ec2 create-volume — volume-type gp2 — size 1 — availability-zone ap-south-1a

Here a elastic block storage of 1GiB is now ready to use.

Step 5 : Finally we are going to attach the above created EBS volume to the instance we created in the previous steps.
#aws ec2 attach-volume — volume-id vol-00a29fe19ed4b9316 — instance-id i-0f31f037d390a80bc — device /dev/sdf

So atlast we successfully attached ebs of 1GiB to our launched instance.
