List of usage examples for com.amazonaws.services.cloudformation.model StackStatus UPDATE_COMPLETE
StackStatus UPDATE_COMPLETE
To view the source code for com.amazonaws.services.cloudformation.model StackStatus UPDATE_COMPLETE.
Click Source Link
From source file:br.com.ingenieux.mojo.cloudformation.AbstractCloudformationMojo.java
License:Apache License
/** * Lookups a Stack//from w w w. ja va 2 s .c o m */ protected void ensureStackLookup() { if (isNotEmpty(stackId)) return; getLog().info("Looking up stackId (stack name: " + stackName + ")"); final Pattern namePattern; if (GlobUtil.hasWildcards(stackName)) { namePattern = GlobUtil.globify(stackName); } else { namePattern = Pattern.compile(Pattern.quote(stackName)); } String nextToken = null; final ListStacksRequest req = new ListStacksRequest().withStackStatusFilters(StackStatus.CREATE_COMPLETE, StackStatus.CREATE_FAILED, StackStatus.UPDATE_COMPLETE); do { req.setNextToken(nextToken); final ListStacksResult result = getService().listStacks(req); final Optional<StackSummary> matchedStackSummary = result.getStackSummaries().stream() .filter(x -> namePattern.matcher(x.getStackName()).matches()).findFirst(); if (matchedStackSummary.isPresent()) { getLog().info("Found stack (stackSummary: " + matchedStackSummary.get()); this.stackId = matchedStackSummary.get().getStackId(); this.stackSummary = matchedStackSummary.get(); return; } nextToken = result.getNextToken(); } while (null != nextToken); throw new IllegalStateException("Stack '" + stackName + "' not found!"); }
From source file:br.com.ingenieux.mojo.cloudformation.PushStackMojo.java
License:Apache License
@Override protected Object executeInternal() throws Exception { shouldFailIfMissingStack(failIfMissing); if (!templateLocation.exists() && !templateLocation.isFile()) { getLog().warn("File not found (or not a file): " + templateLocation.getPath() + ". Skipping."); return null; }/*from w ww .jav a2 s.c o m*/ if (isNotBlank(s3Url)) { getLog().info("Uploading file " + this.templateLocation + " to location " + this.s3Url); s3Client = new BeanstalkerS3Client(getAWSCredentials(), getClientConfiguration(), getRegion()); s3Client.setMultipartUpload(false); this.destinationS3Uri = new AmazonS3URI(s3Url); uploadContents(templateLocation, destinationS3Uri); } else { templateBody = IOUtils.toString(new FileInputStream(this.templateLocation)); } { ValidateTemplateResult validateTemplateResult = validateTemplate(); if (!validateTemplateResult.getParameters().isEmpty()) { Set<String> existingParameterNames = this.parameters.stream().map(x -> x.getParameterKey()) .collect(Collectors.toSet()); Set<String> requiredParameterNames = validateTemplateResult.getParameters().stream() .map(x -> x.getParameterKey()).collect(Collectors.toSet()); for (String requiredParameter : requiredParameterNames) { if (!existingParameterNames.contains(requiredParameter)) { getLog().warn("Missing required parameter name: " + requiredParameter); getLog().warn("If its an update, will reuse previous value"); } this.parameters.add(new com.amazonaws.services.cloudformation.model.Parameter() .withParameterKey(requiredParameter).withUsePreviousValue(true)); } } } WaitForStackCommand.WaitForStackContext ctx = null; Object result = null; if (null == stackSummary) { getLog().info("Must Create Stack"); CreateStackResult createStackResult; result = createStackResult = createStack(); ctx = new WaitForStackCommand.WaitForStackContext(createStackResult.getStackId(), getService(), this::info, 30, asList(StackStatus.CREATE_COMPLETE)); } else { getLog().info("Must Update Stack"); UpdateStackResult updateStackResult; result = updateStackResult = updateStack(); if (null != result) { ctx = new WaitForStackCommand.WaitForStackContext(updateStackResult.getStackId(), getService(), this::info, 30, asList(StackStatus.UPDATE_COMPLETE)); } } if (null != ctx) new WaitForStackCommand(ctx).execute(); return result; }
From source file:com.nike.cerberus.operation.core.UpdateStackOperation.java
License:Apache License
@Override public void run(final UpdateStackCommand command) { final String stackId = configStore.getStackId(command.getStackName()); final Class<? extends LaunchConfigParameters> parametersClass = stackParameterMap .get(command.getStackName()); final Map<String, String> parameters; if (parametersClass != null) { parameters = getUpdateLaunchConfigParameters(command.getStackName(), command, parametersClass); } else if (StackName.BASE == command.getStackName()) { parameters = getUpdatedBaseStackParameters(command); } else {/* w w w.j a v a 2 s. c o m*/ throw new IllegalArgumentException("The specified stack does not support the update stack command!"); } parameters.putAll(command.getDynamicParameters()); try { logger.info("Starting the update for {}.", command.getStackName().getName()); if (command.isOverwriteTemplate()) { cloudFormationService.updateStack(stackId, parameters, stackTemplatePathMap.get(command.getStackName()), true); } else { cloudFormationService.updateStack(stackId, parameters, true); } final StackStatus endStatus = cloudFormationService.waitForStatus(stackId, Sets.newHashSet(StackStatus.UPDATE_COMPLETE, StackStatus.UPDATE_COMPLETE_CLEANUP_IN_PROGRESS, StackStatus.UPDATE_ROLLBACK_COMPLETE)); if (endStatus == StackStatus.ROLLBACK_COMPLETE) { final String errorMessage = String.format("Unexpected end status: %s", endStatus.name()); logger.error(errorMessage); throw new UnexpectedCloudFormationStatusException(errorMessage); } logger.info("Update complete."); } catch (AmazonServiceException ase) { if (ase.getStatusCode() == 400 && StringUtils.equalsIgnoreCase(ase.getErrorMessage(), "No updates are to be performed.")) { logger.warn("CloudFormation reported no changes detected."); } else { throw ase; } } }