Amazon EC2 instance with a specific EBS Volume Size Java SDK

时间:2017-06-15 09:24:47

标签: java amazon-web-services amazon-ec2 sdk

I'm using the java SDK to spin up instances and it's working well. On issue is that the volume is 8GB

RunInstancesRequest runInstancesRequest = new RunInstancesRequest();
runInstancesRequest.withImageId(AMI_ID).withInstanceType(INSTANCE_TYPE).withMinCount(1).withMaxCount(1)
    .withKeyName(KEY_NAME).withSecurityGroups(SECURITY_GROUP).withMonitoring(true);
RunInstancesResult runInstancesResult = ec2.runInstances(runInstancesRequest);

There doesn't seem to be anything in the RunInstancesRequest class but withBlockDeviceMappings seems to create a separate volume. How do you specify the size of the volume?

1 个答案:

答案 0 :(得分:1)

com.amazonaws.services.ec2.model.Volume会帮助你。

Mehtod:setSize(整数大小)

API Documentation