Task Description — AWS
🔅 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 5GB.
🔅 The final step is to attach the above created EBS volume to the instance you created in the previous steps.
First we need to install the AWS cli software in our system. You can download it from here https://amazon.in/cli
Now, After installing the program you can check into the system environment variables the location of the application. So that you can run it into the command prompt directly.
For using the cli we need to configure the AWS credentials. Use AWS configure command to give in the credentials as shown.
STEP1. CREATE A KEY-PAIR FOR THE INSTANCES.
Here you can check a complete guide for using different commands of AWS services , just like key-pair comes under the EC2 service. So we can use aws ec2 help to check the syntax for the different sub commands in it.
To check the syntax of creating a key-pair in aws cli use aws ec2 create-key-pair to show the guide. Here under the synopsis section you will find all the options in that sub command and also it will show different examples to use these options.
Use the command as shown to create and describe the key pair value.
You can confirm the creation of key-pair from the webUI also. And the key will be stored in the directory where you have run the above commands.
STEP2. CREATING A SECURITY GROUP FOR THE INSTANCE
Use aws ec2 create-security-group help command to check the guide and from it you can get the options of group-name and description, And also to create an ingress rule you can use aws ec2 authorize-security-groups-ingress help command as shown.
This security group will allow anyone to connect to the instance on port no 22. As this is used to do ssh with the instances.
STEP3. CREATE AN EBS VOLUME FOR THE INSTANCE
Use aws ec2 create-volume help command to check the guide and run the commands as shown below. According to the need we can also encrypt these volumes.
Here I have created a volume of 5Gib in size. For giving the name to the volume we use
aws ec2 create-tags /
— resources resource id /
— tags Key=Name , Value=VolumeName /
You can use above commands to give the name to the instnaces also.
STEP4. RUN AN INSTANCE
Use aws ec2 run-instances help command to check the syntax and run the commands as shown.
STEP5. ATTACH THE VOLUME AND MOUNT IT.
For attaching the volume use aws ec2 attach-volume help command to check the guide. You need to give the volume-id and instance id and the device name to attach the volume.
After attaching the volume, you need to login to the instance using ssh.
The partition we attached is raw and unlike the s3 it is not a managed service So we have to first create the partitions in the raw device. Use fdisk -l command to check the different partitions attached in the system.
And after this use fdisk device name to go into that partition
here n stands for new, p stands for primary and w stands for save and exit.
These are the commands which can help you to create a primary partition of complete 5 GiB storage. And also we have to format it in the .ext4 format.
Use mkfs.ext4 device name to create a file system.
Now, after formatting the ebs volume create a directory say External storage and mount the ebs device to it.
You can use this ebs device as a pen drive and it can be attached to other instances also. But the Ebs volume cannot be attached to the instances in different regions or subnets.