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

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

Introduction

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

Prototype

StackStatus UPDATE_COMPLETE_CLEANUP_IN_PROGRESS

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

Click Source Link

Usage

From source file:com.nike.cerberus.operation.core.UpdateStackOperation.java

License:Apache License

@Override
public void run(final UpdateStackCommand command) {
    final String stackId = configStore.getStackId(command.getStackName());
    final Class<? extends LaunchConfigParameters> parametersClass = stackParameterMap
            .get(command.getStackName());
    final Map<String, String> parameters;

    if (parametersClass != null) {
        parameters = getUpdateLaunchConfigParameters(command.getStackName(), command, parametersClass);
    } else if (StackName.BASE == command.getStackName()) {
        parameters = getUpdatedBaseStackParameters(command);
    } else {//w w  w.j a  v  a2 s.c  o m
        throw new IllegalArgumentException("The specified stack does not support the update stack command!");
    }

    parameters.putAll(command.getDynamicParameters());

    try {
        logger.info("Starting the update for {}.", command.getStackName().getName());

        if (command.isOverwriteTemplate()) {
            cloudFormationService.updateStack(stackId, parameters,
                    stackTemplatePathMap.get(command.getStackName()), true);
        } else {
            cloudFormationService.updateStack(stackId, parameters, true);
        }

        final StackStatus endStatus = cloudFormationService.waitForStatus(stackId,
                Sets.newHashSet(StackStatus.UPDATE_COMPLETE, StackStatus.UPDATE_COMPLETE_CLEANUP_IN_PROGRESS,
                        StackStatus.UPDATE_ROLLBACK_COMPLETE));

        if (endStatus == StackStatus.ROLLBACK_COMPLETE) {
            final String errorMessage = String.format("Unexpected end status: %s", endStatus.name());
            logger.error(errorMessage);

            throw new UnexpectedCloudFormationStatusException(errorMessage);
        }

        logger.info("Update complete.");
    } catch (AmazonServiceException ase) {
        if (ase.getStatusCode() == 400
                && StringUtils.equalsIgnoreCase(ase.getErrorMessage(), "No updates are to be performed.")) {
            logger.warn("CloudFormation reported no changes detected.");
        } else {
            throw ase;
        }
    }
}