Example usage for com.amazonaws.services.cloudformation.model StackStatus UPDATE_ROLLBACK_FAILED

List of usage examples for com.amazonaws.services.cloudformation.model StackStatus UPDATE_ROLLBACK_FAILED

Introduction

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

Prototype

StackStatus UPDATE_ROLLBACK_FAILED

To view the source code for com.amazonaws.services.cloudformation.model StackStatus UPDATE_ROLLBACK_FAILED.

Click Source Link

Usage

From source file:com.carrotgarden.maven.aws.cfn.CarrotCloudForm.java

License:BSD License

private Stack waitForStackUpdate() throws Exception {

    final long timeStart = System.currentTimeMillis();

    while (true) {

        if (isTimeoutPending(timeStart)) {
            return newStackWithStatus(StackStatus.UPDATE_ROLLBACK_FAILED, "stack update timeout");
        }//from w ww.  j  a v a  2  s  .co m

        Stack stack = null;
        try {
            stack = findStack();
        } catch (final Exception e) {
            return newStackWithStatus(StackStatus.UPDATE_ROLLBACK_FAILED, e.toString());
        }

        if (!isStackValid(stack)) {
            return newStackWithStatus(StackStatus.UPDATE_ROLLBACK_FAILED, "stack update invalid/missing");
        }

        final StackStatus status = StackStatus.fromValue(stack.getStackStatus());

        switch (status) {
        case UPDATE_IN_PROGRESS:
            final long timeCurrent = System.currentTimeMillis();
            final long timeDiff = timeCurrent - timeStart;
            logger.info("stack update in progress; time=" + timeDiff / 1000);
            sleep();
            continue;
        case UPDATE_COMPLETE:
            logger.info("stack update complete");
            printStackEvents();
            return stack;
        default:
            logger.error("stack updtae failed");
            return stack;
        }

    }

}