/** * <p> * Location of file containing the template body. The URL must point to a template that is located in an Amazon S3 * bucket. For more information, go to <a * href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html">Template Anatomy</a> * in the AWS CloudFormation User Guide. * </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 templateURL * Location of file containing the template body. The URL must point to a template that is located in an * Amazon S3 bucket. For more information, go to <a * href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html">Template * Anatomy</a> in the AWS CloudFormation User Guide.</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 withTemplateURL(String templateURL) { setTemplateURL(templateURL); return this; }
/** * <p> * Location of file containing the template body. The URL must point to a template that is located in an Amazon S3 * bucket. For more information, go to <a * href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html">Template Anatomy</a> * in the AWS CloudFormation User Guide. * </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 templateURL * Location of file containing the template body. The URL must point to a template that is located in an * Amazon S3 bucket. For more information, go to <a * href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html">Template * Anatomy</a> in the AWS CloudFormation User Guide.</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 withTemplateURL(String templateURL) { setTemplateURL(templateURL); 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; } }
req.setTemplateURL(cfnTemplateUrl); getLogger().info("Using template url: {}", cfnTemplateUrl);