public Map<String, LaunchConfiguration> describeLaunchConfigs(List<String> launchConfigNames) { if (launchConfigNames.isEmpty()) throw new Error("launchConfigNames must not be empty"); logger.info("describe launch configs, names={}", launchConfigNames); Map<String, LaunchConfiguration> results = Maps.newHashMap(); autoScaling.describeLaunchConfigurations(new DescribeLaunchConfigurationsRequest() .withLaunchConfigurationNames(launchConfigNames)) .getLaunchConfigurations() .forEach(config -> results.put(config.getLaunchConfigurationName(), config)); if (results.size() != launchConfigNames.size()) throw Exceptions.error("some launch config does not exist, foundNames={}", results.keySet()); return results; }
@Override public LaunchConfiguration call() { DescribeLaunchConfigurationsRequest request = new DescribeLaunchConfigurationsRequest() .withLaunchConfigurationNames(this.launchConfigurationName); DescribeLaunchConfigurationsResult result = getClient().getApi().describeLaunchConfigurations(request); List<LaunchConfiguration> launchConfigurations = result.getLaunchConfigurations(); if (launchConfigurations.isEmpty()) { throw new IllegalArgumentException(format("Launch Configuration '%s' doesn't exist in region '%s'.", this.launchConfigurationName, getClient().getRegion())); } return getOnlyElement(launchConfigurations); }
@Override public List<AbstractResource<?>> describeLaunchConfigurations(Account account, Region region, DateTime dt) { AmazonAutoScaling as = findClient(account, region); DescribeLaunchConfigurationsRequest req = new DescribeLaunchConfigurationsRequest(); log.debug("start describing instances for account:{} in region:{} via api", account.getId() + "=>" + account.getName(), region); DescribeLaunchConfigurationsResult res = as.describeLaunchConfigurations(req); return converter.toAsLaunchConfigurations(res.getLaunchConfigurations(), account.getId(), region, dt); }
public LaunchConfiguration describeLaunchConfig(String launchConfigName) { logger.info("describe launch config, name={}", launchConfigName); return autoScaling.describeLaunchConfigurations(new DescribeLaunchConfigurationsRequest() .withLaunchConfigurationNames(launchConfigName)) .getLaunchConfigurations().get(0); }