USING AWS CLI FOR ATTACHING THE EBS WITH THE AWS INSTANCE
OUR TASK:
🔅 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.
All the steps must be performed using the AWS CLI.
Lets , start the task :
First of all we will create a key pair using the AWS CLI:
aws ec2 create-key-pair --key-name task3Key --output text > "C:/Users/milind verma/Downloads/task3Key.pem"
So here we can see that our key is created. I have saved the key into our downloads folder so that we can use it to launch instance and can go into it.
Now we will create the security group using the AWS CLI.
aws ec2 create-security-group --group-name task3SecurityGroup --description "Task 3 security group"
So now our security group is created
Now we will launch an instance using the above security group and the key pair.
you can see here that our instance is launched.
Now we will create an EBS volume using the AWS CLI.
aws ec2 create-volume --volume-type gp2 --size 10 --availability-zone us-west-2b
here our volume is created.
Now we will attach this volume to the instance that we have created earlier.
aws ec2 attach-volume --volume-id vol-095676f069e37f91d --instance-id i-0bb4e48cbb69f75ab --device /dev/sdf
Here our volume is attached to the respective instance
you can see that the volume is now in use for the instance.
So now to check whether the volume is attached or not , we will go inside the instance and mount it.
so now here you can see that we have attached the volume and it is easily accessible.
So finally our task is completed , thanks to the linuxworld and vimal sir for providing us such knowledge.