if (getRollbackConfiguration() != null) sb.append("RollbackConfiguration: ").append(getRollbackConfiguration()).append(","); if (getStackStatus() != null) sb.append("StackStatus: ").append(getStackStatus()).append(","); if (getStackStatusReason() != null) sb.append("StackStatusReason: ").append(getStackStatusReason()).append(",");
@Override public String getStatus() { return getStack().flatMap(stack -> Optional.of(stack.getStackStatus())) // .orElse(STACK_DOES_NOT_EXIST_STATUS); }
@Override public String getStatus() { final Optional<Stack> stack = getStack(); if (!stack.isPresent()) { throw new DeploymentException("Stack " + stackName + " not found"); } return stack.get().getStackStatus(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStackId() == null) ? 0 : getStackId().hashCode()); hashCode = prime * hashCode + ((getStackName() == null) ? 0 : getStackName().hashCode()); hashCode = prime * hashCode + ((getChangeSetId() == null) ? 0 : getChangeSetId().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getParameters() == null) ? 0 : getParameters().hashCode()); hashCode = prime * hashCode + ((getCreationTime() == null) ? 0 : getCreationTime().hashCode()); hashCode = prime * hashCode + ((getDeletionTime() == null) ? 0 : getDeletionTime().hashCode()); hashCode = prime * hashCode + ((getLastUpdatedTime() == null) ? 0 : getLastUpdatedTime().hashCode()); hashCode = prime * hashCode + ((getRollbackConfiguration() == null) ? 0 : getRollbackConfiguration().hashCode()); hashCode = prime * hashCode + ((getStackStatus() == null) ? 0 : getStackStatus().hashCode()); hashCode = prime * hashCode + ((getStackStatusReason() == null) ? 0 : getStackStatusReason().hashCode()); hashCode = prime * hashCode + ((getDisableRollback() == null) ? 0 : getDisableRollback().hashCode()); hashCode = prime * hashCode + ((getNotificationARNs() == null) ? 0 : getNotificationARNs().hashCode()); hashCode = prime * hashCode + ((getTimeoutInMinutes() == null) ? 0 : getTimeoutInMinutes().hashCode()); hashCode = prime * hashCode + ((getCapabilities() == null) ? 0 : getCapabilities().hashCode()); hashCode = prime * hashCode + ((getOutputs() == null) ? 0 : getOutputs().hashCode()); hashCode = prime * hashCode + ((getRoleARN() == null) ? 0 : getRoleARN().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getEnableTerminationProtection() == null) ? 0 : getEnableTerminationProtection().hashCode()); hashCode = prime * hashCode + ((getParentId() == null) ? 0 : getParentId().hashCode()); hashCode = prime * hashCode + ((getRootId() == null) ? 0 : getRootId().hashCode()); hashCode = prime * hashCode + ((getDriftInformation() == null) ? 0 : getDriftInformation().hashCode()); return hashCode; }
public boolean stackExists(String stackName) { try { return describeStack(stackName).stream() // .peek(s -> logger.info("Found stack {}", s)) // .filter(s -> s.getStackName().equals(stackName)) // .anyMatch(s -> !s.getStackStatus().equals("REVIEW_IN_PROGRESS")); } catch (final AmazonCloudFormationException e) { if (e.getStatusCode() == 400) { logger.trace("Got exception {}", e.getMessage(), e); return false; } throw e; } }
if (other.getRollbackConfiguration() != null && other.getRollbackConfiguration().equals(this.getRollbackConfiguration()) == false) return false; if (other.getStackStatus() == null ^ this.getStackStatus() == null) return false; if (other.getStackStatus() != null && other.getStackStatus().equals(this.getStackStatus()) == false) return false; if (other.getStackStatusReason() == null ^ this.getStackStatusReason() == null)
private boolean isInReview() { if (this.exists()) { DescribeStacksResult result = this.client.describeStacks(new DescribeStacksRequest().withStackName(this.stack)); return !result.getStacks().isEmpty() && result.getStacks().get(0).getStackStatus().equals("REVIEW_IN_PROGRESS"); } return false; } }
for (Stack stack : stacks) { if (stack.getStackStatus().contains("FAILED") || stack.getStackStatus().equals(StackStatus.UPDATE_ROLLBACK_COMPLETE.toString()) || stack.getStackStatus().equals(StackStatus.ROLLBACK_COMPLETE.toString()) ) { throw new Exception("Cloudformation failed. Please check AWS Console for details"); if (stack.getStackStatus().equals(StackStatus.UPDATE_COMPLETE.toString()) || stack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString()) ) { completed = true; stackStatus = stack.getStackStatus(); stackReason = stack.getStackStatusReason();
public static boolean waitForCloudFormationStackToReachStatus( AmazonCloudFormationClient client, String stackName, String status) { int count = 0; while (true) { if (count++ == 100) { System.out .println(stackName + " never reached state " + status); return false; } try { Thread.sleep(1000 * 30); } catch (InterruptedException e) { System.out.println(e.getMessage()); return false; } String stackStatus = client .describeStacks( new DescribeStacksRequest() .withStackName(stackName)).getStacks() .get(0).getStackStatus(); if (stackStatus.equals(status)) { return true; } else if (stackStatus.contains(FAILED)) { System.out.println("The process failed with status " + stackStatus); return false; } System.out.println(stackName + " is in status " + stackStatus); } } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStackId() == null) ? 0 : getStackId().hashCode()); hashCode = prime * hashCode + ((getStackName() == null) ? 0 : getStackName().hashCode()); hashCode = prime * hashCode + ((getChangeSetId() == null) ? 0 : getChangeSetId().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getParameters() == null) ? 0 : getParameters().hashCode()); hashCode = prime * hashCode + ((getCreationTime() == null) ? 0 : getCreationTime().hashCode()); hashCode = prime * hashCode + ((getDeletionTime() == null) ? 0 : getDeletionTime().hashCode()); hashCode = prime * hashCode + ((getLastUpdatedTime() == null) ? 0 : getLastUpdatedTime().hashCode()); hashCode = prime * hashCode + ((getRollbackConfiguration() == null) ? 0 : getRollbackConfiguration().hashCode()); hashCode = prime * hashCode + ((getStackStatus() == null) ? 0 : getStackStatus().hashCode()); hashCode = prime * hashCode + ((getStackStatusReason() == null) ? 0 : getStackStatusReason().hashCode()); hashCode = prime * hashCode + ((getDisableRollback() == null) ? 0 : getDisableRollback().hashCode()); hashCode = prime * hashCode + ((getNotificationARNs() == null) ? 0 : getNotificationARNs().hashCode()); hashCode = prime * hashCode + ((getTimeoutInMinutes() == null) ? 0 : getTimeoutInMinutes().hashCode()); hashCode = prime * hashCode + ((getCapabilities() == null) ? 0 : getCapabilities().hashCode()); hashCode = prime * hashCode + ((getOutputs() == null) ? 0 : getOutputs().hashCode()); hashCode = prime * hashCode + ((getRoleARN() == null) ? 0 : getRoleARN().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getEnableTerminationProtection() == null) ? 0 : getEnableTerminationProtection().hashCode()); hashCode = prime * hashCode + ((getParentId() == null) ? 0 : getParentId().hashCode()); hashCode = prime * hashCode + ((getRootId() == null) ? 0 : getRootId().hashCode()); hashCode = prime * hashCode + ((getDriftInformation() == null) ? 0 : getDriftInformation().hashCode()); return hashCode; }
public CompletableFuture<Stack> getStackWhen(String stackName, String... statuses) { DescribeStacksRequest request = new DescribeStacksRequest().withStackName(stackName); return describeStacks(request).thenApply(firstStack()).thenComposeAsync(stack -> { if (ImmutableSet.copyOf(statuses).contains(stack.getStackStatus()) && !stack.getOutputs().isEmpty()) { return CompletableFuture.completedFuture(stack); } else { Threads.sleep(1000); return getStackWhen(stackName, statuses); } }, executor); }
private boolean checkIfStackCreationSucceeded(Stack stack) { StackStatus status = StackStatus.fromValue(stack.getStackStatus()); return status.equals(StackStatus.CREATE_COMPLETE) || status.equals(StackStatus.UPDATE_COMPLETE); }
@TaskAction public void createChangeSet() throws InterruptedException, IOException { // to enable conventionMappings feature String stackName = getStackName(); List<String> stableStatuses = getStableStatuses(); if (stackName == null) { throw new GradleException("stackName is not specified"); } AmazonCloudFormationPluginExtension ext = getProject().getExtensions().getByType(AmazonCloudFormationPluginExtension.class); AmazonCloudFormation cfn = ext.getClient(); DescribeStacksResult describeStackResult = cfn.describeStacks(new DescribeStacksRequest().withStackName(stackName)); Stack stack = describeStackResult.getStacks().get(0); if (stableStatuses.contains(stack.getStackStatus())) { createChangeSet(cfn); } else { throw new GradleException("invalid status for create change set: " + stack.getStackStatus()); } }
stackAttributes.put("accountName", account.getName()); stackAttributes.put("accountId", account.getAccountId()); stackAttributes.put("stackStatus", stack.getStackStatus()); stackAttributes.put("creationTime", stack.getCreationTime()); if (stack.getStackStatus().equals("ROLLBACK_COMPLETE")) { DescribeStackEventsRequest request = new DescribeStackEventsRequest().withStackName(stack.getStackName()); cloudformation.describeStackEvents(request).getStackEvents()
private boolean checkIfStackCreationFailed(Stack stack) { StackStatus status = StackStatus.fromValue(stack.getStackStatus()); return status.equals(StackStatus.CREATE_FAILED) || status.equals( StackStatus.ROLLBACK_FAILED) || status.equals(StackStatus.UPDATE_ROLLBACK_COMPLETE) || status.equals(StackStatus.UPDATE_ROLLBACK_FAILED); } }
stacks.getStacks().stream().filter(stack -> ctx.getStatusesToMatch().contains(StackStatus.fromValue(stack.getStackStatus()))).findFirst();
private boolean waitForStackToBeDeleted() { int retries = 1; Stack stack = null; while (true) { try { stack = getStack(amazonClient.describeStacks()); if (stack == null) { return true; } StackStatus stackStatus = getStackStatus(stack.getStackStatus()); if (StackStatus.DELETE_COMPLETE == stackStatus) { return true; } if (StackStatus.DELETE_FAILED == stackStatus) { return false; } logger.println("Stack status " + stackStatus + "."); } catch (AmazonServiceException ase) { if (!RetryUtils.isThrottlingException(ase)) { throw ase; } } sleep(stack, retries); retries++; } }
Stack stack = describeStackResult.getStacks().get(0); if (stableStatuses.contains(stack.getStackStatus())) { Optional<ChangeSetSummary> summary = getLatestChangeSetSummary(cfn); String changeSetName = summary getLogger().info("ChangeSet is executed : {}, {}", stackName, changeSetName); } else { throw new GradleException("invalid status for update: " + stack.getStackStatus());
cfn.describeStacks(new DescribeStacksRequest().withStackName(stackName)); Stack stack = describeStackResult.getStacks().get(0); if (stack.getStackStatus().equals("DELETE_COMPLETE")) { getLogger().warn("deleted stack {} already exists", stackName); deleteStack(cfn); createStack(cfn); } else if (stableStatuses.contains(stack.getStackStatus())) { updateStack(cfn); } else { throw new GradleException("invalid status for update: " + stack.getStackStatus());
try { stack = getStack(amazonClient.describeStacks(describeStacksRequest)); status = getStackStatus(stack.getStackStatus()); logger.println("Stack status " + status + ". ( " + (subTime - lastTime) + "ms since previous check)"); if (isStackCreationInProgress(status)) {