List of usage examples for com.amazonaws.services.cloudformation AmazonCloudFormation updateStack
UpdateStackResult updateStack(UpdateStackRequest updateStackRequest);
Updates a stack as specified in the template.
From source file:com.netflix.spinnaker.clouddriver.aws.deploy.ops.DeployCloudFormationAtomicOperation.java
License:Apache License
private String updateStack(AmazonCloudFormation amazonCloudFormation, String template, List<Parameter> parameters) { Task task = TaskRepository.threadLocalTask.get(); task.updateStatus(BASE_PHASE, "CloudFormation Stack exists. Updating it"); UpdateStackRequest updateStackRequest = new UpdateStackRequest().withStackName(description.getStackName()) .withParameters(parameters).withTemplateBody(template); task.updateStatus(BASE_PHASE, "Uploading CloudFormation Stack"); try {//from w w w . j a v a 2s.co m UpdateStackResult updateStackResult = amazonCloudFormation.updateStack(updateStackRequest); return updateStackResult.getStackId(); } catch (AmazonCloudFormationException e) { // No changes on the stack, ignore failure return amazonCloudFormation .describeStacks(new DescribeStacksRequest().withStackName(description.getStackName())) .getStacks().stream().findFirst() .orElseThrow(() -> new IllegalArgumentException( "No CloudFormation Stack found with stack name " + description.getStackName())) .getStackId(); } }
From source file:jp.classmethod.aws.gradle.cloudformation.AmazonCloudFormationMigrateStackTask.java
License:Apache License
private void updateStack(AmazonCloudFormation cfn) throws IOException { // to enable conventionMappings feature String stackName = getStackName(); String cfnTemplateUrl = getCfnTemplateUrl(); File cfnTemplateFile = getCfnTemplateFile(); List<Parameter> cfnStackParams = getCfnStackParams(); List<Tag> cfnStackTags = getCfnStackTags(); String cfnStackPolicyUrl = getCfnStackPolicyUrl(); File cfnStackPolicyFile = getCfnStackPolicyFile(); getLogger().info("Update stack: {}", stackName); UpdateStackRequest req = new UpdateStackRequest().withStackName(stackName).withParameters(cfnStackParams) .withTags(cfnStackTags);/*from w w w . j av a2 s . com*/ // If template URL is specified, then use it if (Strings.isNullOrEmpty(cfnTemplateUrl) == false) { req.setTemplateURL(cfnTemplateUrl); getLogger().info("Using template url: {}", cfnTemplateUrl); // Else, use the template file body } else { req.setTemplateBody(FileUtils.readFileToString(cfnTemplateFile)); getLogger().info("Using template file: {}", "$cfnTemplateFile.canonicalPath"); } if (isCapabilityIam()) { Capability selectedCapability = (getUseCapabilityIam() == null) ? Capability.CAPABILITY_IAM : getUseCapabilityIam(); getLogger().info("Using IAM capability: " + selectedCapability); req.setCapabilities(Arrays.asList(selectedCapability.toString())); } // If stack policy is specified, then use it if (Strings.isNullOrEmpty(cfnStackPolicyUrl) == false) { req.setStackPolicyURL(cfnStackPolicyUrl); // Else, use the stack policy file body if present } else if (cfnStackPolicyFile != null) { req.setStackPolicyBody(FileUtils.readFileToString(cfnStackPolicyFile)); } UpdateStackResult updateStackResult = cfn.updateStack(req); getLogger().info("Update requested: {}", updateStackResult.getStackId()); }
From source file:org.xmlsh.aws.gradle.cloudformation.AmazonCloudFormationMigrateStackTask.java
License:BSD License
private void updateStack(AmazonCloudFormation cfn) { // to enable conventionMappings feature String stackName = getStackName(); List<Parameter> cfnStackParams = getCfnStackParams(); getLogger().info("update stack: {}", stackName); UpdateStackRequest req = new UpdateStackRequest().withStackName(stackName).withParameters(cfnStackParams) .withUsePreviousTemplate(isUsePreviousTemplate()); if (getTemplateBody() != null) req.setTemplateBody(getTemplateBody()); if (isCapabilityIam()) { req.setCapabilities(Arrays.asList(Capability.CAPABILITY_IAM.toString())); }//from w w w .ja v a 2 s . c o m UpdateStackResult updateStackResult = cfn.updateStack(req); getLogger().info("update requested: {}", updateStackResult.getStackId()); }
From source file:org.xmlsh.aws.gradle.cloudformation.AmazonCloudFormationUpdateStackTask.java
License:BSD License
private void updateStack(AmazonCloudFormation cfn) { // to enable conventionMappings feature String stackName = getStackName(); List<Parameter> cfnStackParams = getCfnStackParams(); getLogger().info("update stack: {}", stackName); UpdateStackRequest req = new UpdateStackRequest().withStackName(stackName).withParameters(cfnStackParams) .withUsePreviousTemplate(isUsePreviousTemplate()); if (getTemplateBody() != null) req.setTemplateBody(getTemplateBody()); if (isCapabilityIam()) { req.setCapabilities(Arrays.asList(Capability.CAPABILITY_IAM.toString())); }/*w w w. java 2 s . c o m*/ UpdateStackResult updateStackResult = cfn.updateStack(req); getLogger().info("update requested: {}", updateStackResult.getStackId()); }