/** * <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; }
setCapabilities(capabilities); return this;
/** * <p> * A list of <code>Parameter</code> structures that specify input parameters for the stack. For more information, * see the <a * href="http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_Parameter.html">Parameter</a> data * type. * </p> * * @param parameters * A list of <code>Parameter</code> structures that specify input parameters for the stack. For more * information, see the <a * href="http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_Parameter.html">Parameter</a> * data type. * @return Returns a reference to this object so that method calls can be chained together. */ public UpdateStackRequest withParameters(java.util.Collection<Parameter> parameters) { setParameters(parameters); return this; }
capabilitiesCopy.add(value.toString()); if (getCapabilities() == null) { setCapabilities(capabilitiesCopy); } else { getCapabilities().addAll(capabilitiesCopy);
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; } }
}); UpdateStackRequest req = new UpdateStackRequest() .withStackName(stackName) .withParameters(cfnStackParams) .withTags(cfnStackTags); req.setTemplateURL(cfnTemplateUrl); getLogger().info("Using template url: {}", cfnTemplateUrl); req.setTemplateBody(FileUtils.readFileToString(cfnTemplateFile)); getLogger().info("Using template file: {}", "$cfnTemplateFile.canonicalPath"); } else { req.setUsePreviousTemplate(true); getLogger().info("No template specified, updating existing template"); (getUseCapabilityIam() == null) ? Capability.CAPABILITY_IAM : getUseCapabilityIam(); getLogger().info("Using IAM capability: " + selectedCapability); req.setCapabilities(Arrays.asList(selectedCapability.toString())); req.setStackPolicyURL(cfnStackPolicyUrl); req.setStackPolicyBody( FileUtils.readFileToString(cfnStackPolicyFile));
private UpdateStackResult updateStack() throws Exception { UpdateStackRequest req = new UpdateStackRequest().withStackName(stackName).withCapabilities(Capability.CAPABILITY_IAM); if (null != this.destinationS3Uri) { req.withTemplateURL(generateExternalUrl(this.destinationS3Uri)); } else { req.withTemplateBody(templateBody); } req.withNotificationARNs(notificationArns); req.withParameters(parameters); req.withResourceTypes(resourceTypes); req.withTags(tags); try { return getService().updateStack(req); } catch (AmazonServiceException exc) { if ("No updates are to be performed.".equals(exc.getErrorMessage())) { return null; } throw exc; } }
public void execute() { checkParams(); AmazonCloudFormationClient client = getOrCreateClient(AmazonCloudFormationClient.class); UpdateStackRequest request = new UpdateStackRequest() .withStackName(stackName).withStackPolicyBody(stackPolicyBody) .withStackPolicyURL(stackPolicyURL) .withTemplateBody(templateBody).withTemplateURL(templateURL) .withStackPolicyDuringUpdateBody(stackPolicyDuringUpdateBody) .withStackPolicyDuringUpdateURL(stackPolicyDuringUpdateURL) .withUsePreviousTemplate(usePreviousTemplate); if (capabilities.size() > 0) { request.setCapabilities(capabilities); } if (parameters.size() > 0) { request.setParameters(parameters); } if (notificationArns.size() > 0) { request.setNotificationARNs(notificationArns); } try { client.updateStack(request); System.out.println("Update stack " + stackName + " request submitted."); } catch (Exception e) { throw new BuildException("Could not update stack: " + e.getMessage(), e); } }
private UpdateStackRequest updateStackRequest() { UpdateStackRequest r = new UpdateStackRequest(); r.withStackName(getExpandedStackName()); r.withParameters(parameters); r.withTemplateBody(recipe); r.withCapabilities("CAPABILITY_IAM"); return r; }
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()); }
/** * <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> * 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; }
capabilitiesCopy.add(value.toString()); if (getCapabilities() == null) { setCapabilities(capabilitiesCopy); } else { getCapabilities().addAll(capabilitiesCopy);
/** * <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> * 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> * A list of <code>Parameter</code> structures that specify input parameters for the stack. For more information, * see the <a * href="http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_Parameter.html">Parameter</a> data * type. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setParameters(java.util.Collection)} or {@link #withParameters(java.util.Collection)} if you want to * override the existing values. * </p> * * @param parameters * A list of <code>Parameter</code> structures that specify input parameters for the stack. For more * information, see the <a * href="http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_Parameter.html">Parameter</a> * data type. * @return Returns a reference to this object so that method calls can be chained together. */ public UpdateStackRequest withParameters(Parameter... parameters) { if (this.parameters == null) { setParameters(new com.amazonaws.internal.SdkInternalList<Parameter>(parameters.length)); } for (Parameter ele : parameters) { this.parameters.add(ele); } return this; }
setCapabilities(new com.amazonaws.internal.SdkInternalList<String>(capabilities.length));
/** * <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> * A list of <code>Parameter</code> structures that specify input parameters for the stack. For more information, * see the <a * href="http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_Parameter.html">Parameter</a> data * type. * </p> * * @param parameters * A list of <code>Parameter</code> structures that specify input parameters for the stack. For more * information, see the <a * href="http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_Parameter.html">Parameter</a> * data type. * @return Returns a reference to this object so that method calls can be chained together. */ public UpdateStackRequest withParameters(java.util.Collection<Parameter> parameters) { setParameters(parameters); return this; }
setCapabilities(capabilities); return this;