// start only 1 instance
RunInstancesRequest request = new RunInstancesRequest(AMI_ID, 1, 1);
request.setKeyName(KEY_PAIR_NAME);
request.setInstanceType(INS_TYPE);
RunInstancesResult result = ec2.runInstances(request);
List<Instance> instances = result.getReservation().getInstances();
while (!allInstancesStateEqual(instances, InstanceStateName.Running)) {
// instance status should not be Terminated
if (anyInstancesStateEqual(instances, InstanceStateName.Terminated)) {