Search code examples
javaamazon-web-servicessdkcommand-line-interfacevolume

Delete ec2 volume via aws java sdk?


I wanted to delete AWS EC2 volumes which were attached to instances.

But, I could not find any implementation in AWS's java sdk to do so.

Its equivalent cli command is : /usr/bin/aws ec2 delete-volume --volume-id $volumeId

But I want to do it via java sdk.

Any suggestions?


Solution

  • Use deleteVolume(DeleteVolumeRequest request):

    Deletes the specified EBS volume. The volume must be in the available state (not attached to an instance).

    See also: DeleteVolume documentation