Example usage for com.amazonaws.services.cloudformation AmazonCloudFormation listChangeSets

List of usage examples for com.amazonaws.services.cloudformation AmazonCloudFormation listChangeSets

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudformation AmazonCloudFormation listChangeSets.

Prototype

ListChangeSetsResult listChangeSets(ListChangeSetsRequest listChangeSetsRequest);

Source Link

Document

Returns the ID and status of each active change set for a stack.

Usage

From source file:jp.classmethod.aws.gradle.cloudformation.AmazonCloudFormationExecuteChangeSetTask.java

License:Apache License

/**
 *
 * Return the latest ChangeSet Summary for the specified CloudFormation stack.
 * @param cfn AmazonCloudFormation//ww w  .j  a  v a  2  s  . c om
 * @return Optional
 */
private Optional<ChangeSetSummary> getLatestChangeSetSummary(AmazonCloudFormation cfn) {

    ListChangeSetsResult changeSetsResult = cfn
            .listChangeSets(new ListChangeSetsRequest().withStackName(getStackName()));
    List<ChangeSetSummary> changeSetSummaries = changeSetsResult.getSummaries();
    if (changeSetSummaries.isEmpty()) {
        return Optional.empty();
    }

    changeSetSummaries.sort(Comparator.comparing(ChangeSetSummary::getCreationTime).reversed());
    return Optional.of(changeSetSummaries.get(0));
}