Search in sources :

Example 1 with StackStatus

use of com.amazonaws.services.cloudformation.model.StackStatus in project cloudbreak by hortonworks.

the class AwsCreateVpcNetworkTest method getOutputForRequest.

private List<Output> getOutputForRequest(String vpcStackName, AmazonCloudFormation client) {
    int tried = 0;
    while (tried < MAX_TRY) {
        LOGGER.info("checking vpc stack creation result, tried: " + tried + '/' + MAX_TRY);
        DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest();
        describeStacksRequest.withStackName(vpcStackName);
        Stack resultStack = client.describeStacks(describeStacksRequest).getStacks().get(0);
        StackStatus stackStatus = StackStatus.valueOf(resultStack.getStackStatus());
        if (FAILED_STATUSES.contains(stackStatus)) {
            LOGGER.error("stack creation failed: {}", stackStatus);
            throw new RuntimeException();
        } else if (CREATE_COMPLETE.equals(stackStatus)) {
            return resultStack.getOutputs();
        }
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            LOGGER.error("thread sleep interrupted", e);
        }
        tried++;
    }
    throw new RuntimeException("vpc creation timed out");
}
Also used : DescribeStacksRequest(com.amazonaws.services.cloudformation.model.DescribeStacksRequest) StackStatus(com.amazonaws.services.cloudformation.model.StackStatus) Stack(com.amazonaws.services.cloudformation.model.Stack)

Aggregations

DescribeStacksRequest (com.amazonaws.services.cloudformation.model.DescribeStacksRequest)1 Stack (com.amazonaws.services.cloudformation.model.Stack)1 StackStatus (com.amazonaws.services.cloudformation.model.StackStatus)1