In this Blog, we will be creating:
🔅 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.
This is a task given to me in my AWS Training.
To Start with this task, we need to Install AWS CLI on our System and then a IAM Role, which I have already created.
→ Installing AWS CLI Tool on our System:
- We can Download the Package using the following URL:
AWS Command Line Interface
aws-shell is a command-line shell program that provides convenience and productivity features to help both new and…
You will see the following Page and from right hand side, you can click on your desired OS, and hence Install it:
- To Install AWS CLI Tool:
Install this Software and then copy the “bin” Location of this installed Software, In my case it is :
Now, add a Environmental Variable for this copied Location in Path, by following the below Steps:
Click on Environment Variables :
Click on Path, Then Click Edit :
Click on new and then Paste the location here.
To verify if AWS CLI is installed properly or not, we can use the Command “aws — version”,
→ To create a IAM Role, you can refer to the below URL:
Creating a IAM Role on AWS
In this blog, we will be creating a IAM Role, through which we can deploy/create resources on AWS using AWS CLI or any…
- We will create a Key Pair using this command — “aws ec2 create-key-pair — key-name “awscli” ”
2. We will create a Security Group
For creating a security group, we need a default VPC ID. Either we can see from GUI, or from CLI:
VPC ID is “vpc-224d514a”, we can see the similar output from CLI also:
To create Security Group, we use the following command:
“aws ec2 create-security-group — description “This is the Security Group for our Arth Task-5 “ — group-name “Arth-task5-sg” — vpc-id vpc-224d514a”
To connect to Instance, we must have to attach some rules to it, otherwise we can’t use this instance.
As you can see, we dont have any rules pre-written, so we can’t do SSH also. So following is the command to attach some rules to it, here I want only SSH which uses “tcp” protocol and port number “22”, CIDR Range i am giving as “0.0.0.0/0”, as I want that from any IP, I can connect to it.
Command is : “aws ec2 authorize-security-group-ingress — group-name Arth-task5-sg — protocol tcp — port 22 — cidr 0.0.0.0/0”
After we run the above command, we can see that rule is added.
3. Creating a Instance:
We want key name, using following we can get the key names:
To create a Instance:
“ aws ec2 run-instances — key-name “awscli” — instance-type “t2.micro” — count 2 — security-group-ids sg-06ea64703f36ae12f — image-id ami-08e0ca9924195beba ”
4. Creating a EBS Volume of 1 GB
We can create a Volume using the command: “ aws ec2 create-volume — size 1 — availability-zone “ap-south-1a” ”
5. Attaching EBS Volume to one of the Instance:
We use the following command:- “aws ec2 attach-volume — device /dev/xvdb — instance-id i-0f5402d77697e3efb — volume-id vol-07d20ffccd5259816”
In this command, we have to give ID of the Volume and Id of the Instance, either we can fetch ID’s from GUI or from CLI.
From the above command, we can fetch the Volume’s Details and see that which volume is free and can be attached.
As this service is regional, so we can’t attach volume, which is being created in other regions, compared to the region in which Instance is created.
In my case, region is “ap-south-1b”.
→ Connecting to the instance:
I have used “Putty” Software, from which I have done SSH.
As we can see that disk is attached.
“I have practiced and gained all knowledge of this project(task) under the mentorship of Mr. VIMAL DAGA Sir during the AWS Training by Linux World India.”
I hope this article is Informative and Explanatory. Hope you like it !!!
For any suggestions or if any reader find any flaw in this article, please email me to “email@example.com”
Thank You Readers, for viewing this !!!