public static List < Instance > runInstances ( final String imageId , final int runCount ) { // 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 ) ; // instance type String instanceType = "m1.large" ; // run 10 instances RunInstancesRequest request = new RunInstancesRequest ( ) ; final int minRunCount = runCount ; final int maxRunCount = runCount ; request . withImageId ( imageId ) . withInstanceType ( instanceType ) . withMinCount ( minRunCount ) . withMaxCount ( maxRunCount ) ; RunInstancesResult result = amazonEC2Client . runInstances ( request ) ; return result . getReservation ( ) . getInstances ( ) ; }
Run some new ec2 instances .