Search in sources :

Example 1 with UpdateStackRequest

use of com.amazonaws.services.cloudformation.model.UpdateStackRequest in project pipeline-aws-plugin by jenkinsci.

the class CloudFormationStack method update.

public void update(String templateBody, String templateUrl, Collection<Parameter> params, Collection<Tag> tags, long pollIntervallMillis, String roleArn) throws ExecutionException {
    try {
        UpdateStackRequest req = new UpdateStackRequest();
        req.withStackName(this.stack).withCapabilities(Capability.CAPABILITY_IAM, Capability.CAPABILITY_NAMED_IAM);
        if (templateBody != null && !templateBody.isEmpty()) {
            req.setTemplateBody(templateBody);
        } else if (templateUrl != null && !templateUrl.isEmpty()) {
            req.setTemplateURL(templateUrl);
        } else {
            req.setUsePreviousTemplate(true);
        }
        req.withParameters(params).withTags(tags).withRoleARN(roleArn);
        this.client.updateStack(req);
        new EventPrinter(this.client, this.listener).waitAndPrintStackEvents(this.stack, this.client.waiters().stackUpdateComplete(), pollIntervallMillis);
        this.listener.getLogger().format("Updated CloudFormation stack %s %n", this.stack);
    } catch (AmazonCloudFormationException e) {
        if (e.getMessage().contains("No updates are to be performed")) {
            this.listener.getLogger().format("No updates were needed for CloudFormation stack %s %n", this.stack);
            return;
        }
        this.listener.getLogger().format("Failed to update CloudFormation stack %s %n", this.stack);
        throw e;
    }
}
Also used : AmazonCloudFormationException(com.amazonaws.services.cloudformation.model.AmazonCloudFormationException) UpdateStackRequest(com.amazonaws.services.cloudformation.model.UpdateStackRequest)

Aggregations

AmazonCloudFormationException (com.amazonaws.services.cloudformation.model.AmazonCloudFormationException)1 UpdateStackRequest (com.amazonaws.services.cloudformation.model.UpdateStackRequest)1