Untitled
unknown
plain_text
a month ago
1.8 kB
3
Indexable
Never
public Map<String, String> getiT(List<String> instanceIds) { log.info("Get SSM capability for instances {}", instanceIds); Map<String, String> iT = new HashMap<>(); InstanceInformationFilter instanceInformationFilter = new InstanceInformationFilter() .withKey(InstanceInformationFilterKey.InstanceIds) .withValueSet(instanceIds); DescribeInstanceInformationRequest describeInstanceInformationRequest = new DescribeInstanceInformationRequest() .withInstanceInformationFilterList(Collections.singletonList(instanceInformationFilter)); DescribeInstanceInformationResult describeInstanceInformationResult = this.ssmClient.describeInstanceInformation (describeInstanceInformationRequest); List<InstanceInformation> instanceInfoList = describeInstanceInformationResult.getInstanceInformationList(); if (!instanceInfoList.isEmpty()) { String ssmCapability; for (InstanceInformation instanceInfo : instanceInfoList) { ssmCapability = instanceInfo.getComputerName(); log.info("Instance: {} has computer name: {}", instanceInfo.getInstanceId(), ssmCapability); if (ssmCapability == null) { log.error("Get null computerName for instance {}", instanceInfo); } else if (!ssmCapability.equals("dual") && !ssmCapability.equals("endpoint")) { ssmCapability = "shell"; } iT.put(instanceInfo.getInstanceId(), ssmCapability); log.info("Instance: {} has SSM capability: {}", instanceInfo.getInstanceId(), ssmCapability); } } else { log.info("No instanceInfoList found for instances {}", instanceIds); } return iT; }
Leave a Comment