use of org.finra.gatekeeper.services.accessrequest.model.AWSInstance in project Gatekeeper by FINRAOS.
the class AccessRequestService method updateInstanceStatus.
public AccessRequest updateInstanceStatus(AccessRequest accessRequest) {
AWSEnvironment environment = new AWSEnvironment(accessRequest.getAccount(), accessRequest.getRegion());
List<AWSInstance> requestedInstances = accessRequest.getInstances();
List<String> instanceIds = requestedInstances.stream().map(instance -> instance.getInstanceId()).collect(Collectors.toList());
Map<String, String> instances = ssmService.checkInstancesWithSsm(environment, instanceIds);
requestedInstances.forEach(instance -> instance.setStatus(instances.get(instance.getInstanceId()) != null ? instances.get(instance.getInstanceId()) : "Unknown"));
accessRequest.setInstances(requestedInstances);
accessRequestRepository.save(accessRequest);
return accessRequest;
}
Aggregations