class InstanceFailureStepDefinitions implements EC2StepFunctions {

    @When("^terminate (\\d+) instance$")
    public InstanceFailureStepDefinitions terminateInstanceOnNumInstances(int numInstances) {
        List<EC2InstanceTO> instances = executionStateCache.getInstances();
        if (instances == null || instances.isEmpty()) {
            throw new RuntimeException("Unable to terminate process, no instances available");
        }

        if (numInstances > instances.size()) {
            numInstances = instances.size();
        }

        IntStream.range(0, numInstances)
                .parallel()
                .forEach(
                        i ->
                        {
                            terminationHelper(instances.get(i).getInstanceId(), instances.get(i).getPrivateIpAddress());
                        });

        return this;
    }

    public  InstanceFailureStepDefinitions();

}