LOGGER.info("Adding new instances to metadata: [stack: '{}']", stack.getId());
AmazonEC2Client amazonEC2Client = awsStackUtil.createEC2Client(
((AwsTemplate) stack.getTemplate()).getRegion(),
(AwsCredential) stack.getCredential());
List<String> instanceIds = cfStackUtil.getInstanceIds(stack);
DescribeInstancesRequest instancesRequest = new DescribeInstancesRequest().withInstanceIds(instanceIds);
DescribeInstancesResult instancesResult = amazonEC2Client.describeInstances(instancesRequest);
for (Reservation reservation : instancesResult.getReservations()) {
for (final com.amazonaws.services.ec2.model.Instance instance : reservation.getInstances()) {
boolean metadataExists = FluentIterable.from(stack.getInstanceMetaData()).anyMatch(new Predicate<InstanceMetaData>() {
@Override