Amazon AWS creating EBS(Elastic block storage) through Java API
amazon-ec2, amazon-web-services, java
Solution
You should be able to use createVolume to create the item. That looks to return a CreateVolumeResult, which has a `Volume` object inside.
You would then take the `Volume` returned from the `createVolume` call and attachVolume with a matching AttachVolumeRequest.
This is all done after you create one of AWS `AmazonEC2Client` objects: documentation is all pulled from here.
Workflow of the code would probably look like this (note: pseudo code is used and there may be a few more pieces to hook in but the workflow should look something like this)
AWSCredentials credentials = new AWSCredentials();
AmazonEC2Client client = new AmazonEC2Client(credentials);
CreateVolumeResult request = new CreateVolumeRequest(java.lang.Integer size,
java.lang.String availabilityZone);
CreateVolumeResponse volumeResponse = client.createVolume(request);
AttachVolumeRequest attachRequest = new AttachVolumeRequest(volumeResponse.getVolume().getVolumeId(), java.lang.String instanceId, java.lang.String device);
client.attachVolume(attachRequest);
Problem
I am trying to find a way to create a new EBS and attach it to a running instance pro grammatically through the AWSJavaSDK. I see ways to do this with command line tools and with rest based calls but no way through the SDK proper.