AWS — Task 2

Peeyush Yadav
5 min readOct 14, 2020

Created By: Peeyush Yadav

This task is in correspondence to the Training on AWS-CA, which is instructed and guided by Mr. Vimal Daga. This task pretty much takes on all the concepts that the training has covered so far (in 6 sessions). The goal of this task is as follows:

Perform the following tasks by the use of AWS CLI only.

Task description:

-> Create a key pair

-> Create a security group

->Launch an instance using the above created key pair and security group

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

In order to follow the rest of the steps, we must create a sub-user so that we can log in using access, secret key pair.

For the same, these steps are to be followed.

-> Login into AWS using your root account credential

->Hover over to IAM and click on it

-> Click on the user. By default, it shows the number of sub-users created within the same root user.

-> Click ‘Add User’, put in the asked credentials, such as name, access types, etc.

-> Choose the type of Policy you want to provide the sub-user.

->Add tags : values (optional)

Now that, these steps are over, you will need to go to AWS CLI

-> Open the AWS CLI

->Type in aws configure

-> The prompt asks for the access key and secret key, copy the same from the sub-user you just created in the previous set of steps.

-> Set the region and output format (here, I’ve set region as ap-south-1, for Mumbai, and JSON for output format)

-> Next to create your key-pair type in the following command: aws ec2 create-key-pair –key-name <your preferred key pair name>

-> To verify, you can head over to “Key Pairs” later, and this would look something like this

-> Next job is to create a security group for your instance and to do that, type the following command: aws ec2 create-security-group –group-name <specify a Security group name> — description “<specify the description within the quotes>” –vpc-id <your vpc id here, starts with vpc-XXXXXX>

-> Over the WebUI the latter should look something like this.

-> Now, we must allow some sort of external traffic to be able to access the instance out of the WebUI, to do the same, type in :

aws es2 authorize-security-group-ingress –group-id <your security group id here> — group-name <your security group name> — protocol <protocol type> — port <port number> — cidr <addresses to allocate>

-> You can check the changes as

-> Now we launch an instance. This can be done by ,

aws ec2 run-instances –image-id <your AMI id here> — instance-type <type of instance, t2.micro (for example)> — count <number of instances you want to create> — subnet-id <specify the subnet-id corresponding to the suitable region and zone> — security-group-ids <security group-id from the security group created in the previous steps> — key-name <key-pair name from the latter created in the previous step>

-> Once done creating, the instance can be checked for status in the “Instances” tab in the WebUI

-> Towards the end of this task, we now need to create an EBS volume drive of a specific size (1GB in this case). To do the same, type in: aws ec2 create-volume — volume-type <any available volume type> — size <enter the size in Gigabytes> — availability-zone <specify your availability-zone>

-> The same can be confirmed when the “Volumes” tab is updated.

-> One final step remains, wherein this idle storage volume is to be attached to an instance. For doing the same: aws ec2 attach-volume –instance-id <your instance-id from the previous steps> — volume-id <volume id of the volume to be attached> — device <device-type, which is currently not in use>

-> To verify the same, the in WebUI, head over to the “Volumes” tab and hover over to the volume info. The typical “Attachment” value is not empty for a volume that is attached to an instance and blank otherwise.

That’s it! The task is completed.

I thank Mr. Vimal Daga and the Linux World Team for their guidance and support towards us.

--

--