LOGGER.info(String.format("Terminating instance %s in region %s.", instanceId, region));
try {
ec2Client().terminateInstances(new TerminateInstancesRequest(Arrays.asList(instanceId)));
} catch (AmazonServiceException e) {
if (e.getErrorCode().equals("InvalidInstanceID.NotFound")) {
throw new NotFoundException("AWS instance " + instanceId + " not found", e);
}
throw e;
}
}