private UpdateStackRequest updateStackRequest() { UpdateStackRequest r = new UpdateStackRequest(); r.withStackName(getExpandedStackName()); r.withParameters(parameters); r.withTemplateBody(recipe); r.withCapabilities("CAPABILITY_IAM"); return r; }
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()); }
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; } }