List<String> instanceIds = new ArrayList<String>();
for (Instance i : envResources.getEnvironmentResources().getInstances())
instanceIds.add(i.getId());
DescribeInstancesResult ec2Instances = ec2
.describeInstances(new DescribeInstancesRequest()
.withInstanceIds(instanceIds));
PrintStream printStream = null;
if (null != outputFile)
printStream = new PrintStream(outputFile);
for (Reservation r : ec2Instances.getReservations()) {
for (com.amazonaws.services.ec2.model.Instance i : r.getInstances()) {
String ipAddress = dumpPrivateAddresses ? i
.getPrivateIpAddress() : StringUtils.defaultString(
i.getPublicIpAddress(), i.getPrivateDnsName());
String instanceId = i.getInstanceId();