AWS CLI

Upmanyu Sharma
4 min readJan 7, 2021

Task Description — AWS*_

1) Create a key pair

2)Create a security group

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

4)Create an EBS volume of 1 GB.

5) The final step is to attach the above created EBS volume to the instance you created in the previous steps.

Here it begins,

First of all, we have to create IAM user.

AWS provides us IAM services where we can create user and give access to that user.

Step 1 :

We have to set user details by giving user name(can add multiple users at once also) and then choose Programmatic Access type as AWS access type for AWS CLI.

Step 2:

We have to set the permission which we want to give to the user.

I have given Power Access to the user.

Step 3:

AWS will create the user and provide you Access key and Secret Access for that user. Now you can use them to login into our AWS CLI.

So you can see user “awsuser1” is created.

Now, we have to login to AWS CLI using Command Prompt.

For that, we have to use the command “awsconfigure” and we have to provide an access key and secret access key to login to AWS CLI.

We can use the command “aws help” to get all the commands to enable services.

For eg we want to use ec2 services.

We can run the command “aws ec2 help” to get all the subcommands for ec2 services.

1. Create a key pair

We have to create key pair for that we can take the help of AWS by writing command

aws ec2 help

This command will give us all the commands in ec2.

Now, we can see the sub-command to create a key pair.

We can create a new key pair by running the command :

aws ec2 create-key-pair — key-name Mykey

2) Create a security group

To create a security group we can run the command as follows:

aws ec2 create security-group –group-name SecurityGroup –description “Security Group”

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

Command:

aws ec2 run-instances — image-id ami-0e306788ff2473ccb — instance-type t2.micro — subnet-id subnet-0b606963 — count 1 — security-group-ids sg-09007a4edb9fed422 — keky0name MyKey

Now you can see that a new instance is launched in CLI.

You can see it in GUI also.

Here above you can see the instance running.

4) Create an EBS volume of 1 GB.

Command: aws ec2 create-volume — availability-zone ap-south-1a — size 1

You can see the EBS volume size created.

We can see the EBS volume size on GUI also.

5) The final step is to attach the above created EBS volume to the instance you created in the previous steps.

aws ec2 attach-volume — instance-id i-09c153c2d1f021ff6 — device /dev/sdf — volume-id vol-0f7c3ce9613bac95b

Now You can see that EBS is in use State in AWS GUI.

Thanks to All for Reading my Article

--

--