/** * <p> * Structure containing the template body with a minimum length of 1 byte and a maximum length of 51,200 bytes. (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 templateBody * Structure containing the template body with a minimum length of 1 byte and a maximum length of 51,200 * bytes. (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 withTemplateBody(String templateBody) { setTemplateBody(templateBody); return this; }
/** * <p> * Structure containing the template body with a minimum length of 1 byte and a maximum length of 51,200 bytes. (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 templateBody * Structure containing the template body with a minimum length of 1 byte and a maximum length of 51,200 * bytes. (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 withTemplateBody(String templateBody) { setTemplateBody(templateBody); 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; } }
protected void updateStack(Deployment deployment, String templateBody) throws Exception { String templateName = deployment.getCloudFormationStackName(); UpdateStackRequest updateStackRequest = new UpdateStackRequest(); updateStackRequest.setStackName(templateName); updateStackRequest.setTemplateBody(templateBody); updateStackRequest.setParameters(deployment.getCloudFormationParameters()); updateStackRequest.withCapabilities(Capability.CAPABILITY_IAM); getCloudFormationClient().updateStack(updateStackRequest); log.info("Stack update completed, the stack " + templateName + " completed with " + waitForCompletion()); }
req.setTemplateBody(FileUtils.readFileToString(cfnTemplateFile)); getLogger().info("Using template file: {}", "$cfnTemplateFile.canonicalPath"); } else {