List of usage examples for com.amazonaws.services.autoscaling AmazonAutoScalingClient describeLaunchConfigurations
@Override
public DescribeLaunchConfigurationsResult describeLaunchConfigurations(
DescribeLaunchConfigurationsRequest request)
Describes one or more launch configurations.
From source file:com.netflix.simianarmy.client.aws.AWSClient.java
License:Apache License
/** * Describe a set of specific launch configurations. * * @param names the launch configuration names * @return the launch configurations/*w w w. j av a 2 s .co m*/ */ public List<LaunchConfiguration> describeLaunchConfigurations(String... names) { if (names == null || names.length == 0) { LOGGER.info(String.format("Getting all launch configurations in region %s.", region)); } else { LOGGER.info(String.format("Getting launch configurations for %d names in region %s.", names.length, region)); } List<LaunchConfiguration> lcs = new LinkedList<LaunchConfiguration>(); AmazonAutoScalingClient asgClient = asgClient(); DescribeLaunchConfigurationsRequest request = new DescribeLaunchConfigurationsRequest() .withLaunchConfigurationNames(names); DescribeLaunchConfigurationsResult result = asgClient.describeLaunchConfigurations(request); lcs.addAll(result.getLaunchConfigurations()); while (result.getNextToken() != null) { request.setNextToken(result.getNextToken()); result = asgClient.describeLaunchConfigurations(request); lcs.addAll(result.getLaunchConfigurations()); } LOGGER.info(String.format("Got %d launch configurations in region %s.", lcs.size(), region)); return lcs; }
From source file:io.macgyver.plugin.cloud.aws.scanner.LaunchConfigScanner.java
License:Apache License
private void forEachLaunchConfig(Region region, Consumer<LaunchConfiguration> consumer) { AmazonAutoScalingClient client = new AmazonAutoScalingClient(getAWSServiceClient().getCredentialsProvider()) .withRegion(region);/*from ww w. ja v a 2 s. c o m*/ DescribeLaunchConfigurationsResult results = client .describeLaunchConfigurations(new DescribeLaunchConfigurationsRequest()); String token = results.getNextToken(); results.getLaunchConfigurations().forEach(consumer); while (!Strings.isNullOrEmpty(token) && !token.equals("null")) { results = client .describeLaunchConfigurations(new DescribeLaunchConfigurationsRequest().withNextToken(token)); token = results.getNextToken(); results.getLaunchConfigurations().forEach(consumer); } }