Example usage for com.amazonaws.services.cloudformation.model AmazonCloudFormationException getStatusCode

List of usage examples for com.amazonaws.services.cloudformation.model AmazonCloudFormationException getStatusCode

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudformation.model AmazonCloudFormationException getStatusCode.

Prototype

public int getStatusCode() 

Source Link

Document

Returns the HTTP status code that was returned with this service exception.

Usage

From source file:com.github.kaklakariada.aws.sam.service.CloudformationService.java

License:Open Source License

public boolean stackExists(String stackName) {
    try {//from  w  w w . j a v  a 2  s  . com
        return describeStack(stackName).stream() //
                .peek(s -> logger.info("Found stack {}", s)) //
                .filter(s -> s.getStackName().equals(stackName)) //
                .anyMatch(s -> !s.getStackStatus().equals("REVIEW_IN_PROGRESS"));
    } catch (final AmazonCloudFormationException e) {
        if (e.getStatusCode() == 400) {
            logger.trace("Got exception {}", e.getMessage(), e);
            return false;
        }
        throw e;
    }
}

From source file:com.github.kaklakariada.aws.sam.service.poll.StackStatusWaitCondition.java

License:Open Source License

protected Optional<Stack> getStack() {
    final List<Stack> stacks;
    try {/*w  ww  .  ja v  a2 s  .  c  o m*/
        stacks = cloudFormation.describeStacks(new DescribeStacksRequest().withStackName(stackName))
                .getStacks();
    } catch (final AmazonCloudFormationException e) {
        if (e.getStatusCode() == 400) {
            return Optional.empty();
        }
        throw e;
    }
    if (stacks.isEmpty()) {
        return Optional.empty();
    }
    if (stacks.size() > 1) {
        throw new DeploymentException("Found more than one stack for name '" + stackName + "'");
    }
    final Stack stack = stacks.get(0);
    return Optional.of(stack);
}