public static List<InstanceStateChange> stopInstances(final List<String> instanceIDs) {
        // pass any credentials as aws-mock does not authenticate them at all
        AWSCredentials credentials = new BasicAWSCredentials("foo", "bar");
        AmazonEC2Client amazonEC2Client = new AmazonEC2Client(credentials);

        // the mock endpoint for ec2 which runs on your computer
        String ec2Endpoint = "http://localhost:8000/aws-mock/ec2-endpoint/";
        amazonEC2Client.setEndpoint(ec2Endpoint);

        // send the stop request with args as instance IDs to stop running instances
        StopInstancesRequest request = new StopInstancesRequest();
        request.withInstanceIds(instanceIDs);
        StopInstancesResult result = amazonEC2Client.stopInstances(request);

        return result.getStoppingInstances();
    }
public static List < InstanceStateChange > stopInstances ( final List < String > instanceIDs ) { AWSCredentials credentials = new BasicAWSCredentials ( "foo" , "bar" ) ; AmazonEC2Client amazonEC2Client = new AmazonEC2Client ( credentials ) ; String ec2Endpoint = "http://localhost:8000/aws-mock/ec2-endpoint/" ; amazonEC2Client . setEndpoint ( ec2Endpoint ) ; StopInstancesRequest request = new StopInstancesRequest ( ) ; request . withInstanceIds ( instanceIDs ) ; StopInstancesResult result = amazonEC2Client . stopInstances ( request ) ; return result . getStoppingInstances ( ) ; }
Stop specified instances (power-on the instances).

@param instanceIDs
IDs of the instances to stop
@return a list of state changes for the instances