/** * <p> * Reuse the existing template that is associated with the stack that you are updating. * </p> * <p> * Conditional: You must specify only one of the following parameters: <code>TemplateBody</code>, * <code>TemplateURL</code>, or set the <code>UsePreviousTemplate</code> to <code>true</code>. * </p> * * @param usePreviousTemplate * Reuse the existing template that is associated with the stack that you are updating.</p> * <p> * Conditional: You must specify only one of the following parameters: <code>TemplateBody</code>, * <code>TemplateURL</code>, or set the <code>UsePreviousTemplate</code> to <code>true</code>. * @return Returns a reference to this object so that method calls can be chained together. */ public UpdateStackRequest withUsePreviousTemplate(Boolean usePreviousTemplate) { setUsePreviousTemplate(usePreviousTemplate); return this; }
/** * <p> * Reuse the existing template that is associated with the stack that you are updating. * </p> * <p> * Conditional: You must specify only one of the following parameters: <code>TemplateBody</code>, * <code>TemplateURL</code>, or set the <code>UsePreviousTemplate</code> to <code>true</code>. * </p> * * @param usePreviousTemplate * Reuse the existing template that is associated with the stack that you are updating.</p> * <p> * Conditional: You must specify only one of the following parameters: <code>TemplateBody</code>, * <code>TemplateURL</code>, or set the <code>UsePreviousTemplate</code> to <code>true</code>. * @return Returns a reference to this object so that method calls can be chained together. */ public UpdateStackRequest withUsePreviousTemplate(Boolean usePreviousTemplate) { setUsePreviousTemplate(usePreviousTemplate); return this; }
public Map<String, String> update(String templateBody, String templateUrl, Collection<Parameter> params, Collection<Tag> tags, PollConfiguration pollConfiguration, String roleArn, RollbackConfiguration rollbackConfig) throws ExecutionException { try { UpdateStackRequest req = new UpdateStackRequest(); req.withStackName(this.stack).withCapabilities(Capability.CAPABILITY_IAM, Capability.CAPABILITY_NAMED_IAM, Capability.CAPABILITY_AUTO_EXPAND); if (templateBody != null && !templateBody.isEmpty()) { req.setTemplateBody(templateBody); } else if (templateUrl != null && !templateUrl.isEmpty()) { req.setTemplateURL(templateUrl); } else { req.setUsePreviousTemplate(true); } req.withRollbackConfiguration(rollbackConfig); req.withParameters(params).withTags(tags).withRoleARN(roleArn); this.client.updateStack(req); new EventPrinter(this.client, this.listener).waitAndPrintStackEvents(this.stack, this.client.waiters().stackUpdateComplete(), pollConfiguration); this.listener.getLogger().format("Updated CloudFormation stack %s %n", this.stack); Map<String, String> outputs = this.describeOutputs(); outputs.put(UPDATE_STATUS_OUTPUT, "true"); return outputs; } 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); Map<String, String> outputs = this.describeOutputs(); outputs.put(UPDATE_STATUS_OUTPUT, "false"); return outputs; } this.listener.getLogger().format("Failed to update CloudFormation stack %s %n", this.stack); throw e; } }
getLogger().info("Using template file: {}", "$cfnTemplateFile.canonicalPath"); } else { req.setUsePreviousTemplate(true); getLogger().info("No template specified, updating existing template");