public static List<RunningInstance> getEC2RunningInstances(String awsAccessKey, String awsSecretKey,
			String awsRegion) {
		Assert.hasText(awsAccessKey, "awsAccessKey must not be empty nor null");
		Assert.hasText(awsSecretKey, "awsSecretKey must not be empty nor null");
		Assert.hasText(awsRegion, "awsRegion must not be empty nor null");

		AWSEC2Api client = ContextBuilder.newBuilder("aws-ec2")
				.credentials(awsAccessKey, awsSecretKey)
				.buildApi(AWSEC2Api.class);
		Set<? extends Reservation<? extends AWSRunningInstance>> reservations = client
				.getInstanceApi().get().describeInstancesInRegion(awsRegion);
		int instanceCount = reservations.size();
		ArrayList<RunningInstance> result = new ArrayList<RunningInstance>();
		for (int awsRunningInstanceCount = 0; awsRunningInstanceCount < instanceCount; awsRunningInstanceCount++) {
			Reservation<? extends AWSRunningInstance> instances = Iterables
					.get(reservations, awsRunningInstanceCount);
			int groupCount = instances.size();
			for (int runningInstanceCount = 0; runningInstanceCount < groupCount; runningInstanceCount++) {
				result.add(Iterables.get(instances, runningInstanceCount));
			}
		}
		return result;
	}
Returns a list of active instances from the specified ec2 region.
@param awsAccessKey the unique id of the ec2 user.
@param awsSecretKey the password of ec2 user.
@param awsRegion The aws region to inspect for acceptance test instances.
@return a list of active instances in the account and region specified.
spring-xd-integration-test/src/main/java/org/springframework/xd/integration/util/StreamUtils.java