Create Ebs volume for EC2 instance with AWS-CLI

Ayanchawla
Oct 17, 2020

EBS is elastic block storage, it works like a pendrive for your OS but be careful that you have to select availability zone same as EC2 instance.

There are many types of volumes but default is gp2. These are gp2 for General Purpose SSD, io1 or io2 for Provisioned IOPS SSD, st1 for Throughput Optimized HDD, sc1 for Cold HDD, or standard for Magnetic volumes.

Next you have to select the size you want to give, 30 GB is free to use in total in AWS.

Command to Create it is

aws ec2 create-volume --volume-type gp2 --size sizeInGiB \
--availability-zone zoneID

By default is gp2. If you run command

aws ec2 create-volume --size sizeInGiB --availability-zone zoneID

To connect it with EC2 instance. Click

To Delete any created Volume -

First check its volume id by command

aws ec2 describe-volumes

It will list all the commands, now select the volume id you want to delete.

aws ec2 delete-volume --volume-id ebsVolumeID

It will delete you created volume.

Note — Always make sure to detach the volume before you delete it.

To see how to detach Click

Thank You for Reading

I would like to thanks Vimal Daga Sir. (https://www.linkedin.com/in/vimaldaga/)

Email — ayanchawlae@gmail.com

LinkedIn — https://www.linkedin.com/in/ayanchawlae/

--

--