List of usage examples for com.amazonaws.services.cloudformation.model StackStatus CREATE_FAILED
StackStatus CREATE_FAILED
To view the source code for com.amazonaws.services.cloudformation.model StackStatus CREATE_FAILED.
Click Source Link
From source file:CloudFormation.java
License:Open Source License
public static String waitForCompletion(AmazonCloudFormation stackbuilder, String stackName) throws Exception { DescribeStacksRequest wait = new DescribeStacksRequest(); wait.setStackName(stackName);/*from w w w .j a v a2 s . co m*/ Boolean completed = false; String stackStatus = "Unknown"; String stackReason = ""; System.out.print("Waiting"); while (!completed) { List<Stack> stacks = stackbuilder.describeStacks(wait).getStacks(); if (stacks.isEmpty()) { completed = true; stackStatus = "NO_SUCH_STACK"; stackReason = "Stack has been deleted"; } else { for (Stack stack : stacks) { if (stack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString()) || stack.getStackStatus().equals(StackStatus.CREATE_FAILED.toString()) || stack.getStackStatus().equals(StackStatus.ROLLBACK_FAILED.toString()) || stack.getStackStatus().equals(StackStatus.DELETE_FAILED.toString())) { completed = true; stackStatus = stack.getStackStatus(); stackReason = stack.getStackStatusReason(); } } } // Show we are waiting System.out.print("."); // Not done yet so sleep for 10 seconds. if (!completed) Thread.sleep(10000); } // Show we are done System.out.print("done\n"); return stackStatus + " (" + stackReason + ")"; }
From source file:br.com.ingenieux.mojo.cloudformation.AbstractCloudformationMojo.java
License:Apache License
/** * Lookups a Stack// ww w. jav a 2 s . c om */ 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:com.carrotgarden.maven.aws.cfn.CarrotCloudForm.java
License:BSD License
private Stack waitForStackCreate() throws Exception { final long timeStart = System.currentTimeMillis(); while (true) { if (isTimeoutPending(timeStart)) { return newStackWithStatus(StackStatus.CREATE_FAILED, "stack create timeout"); }/*from www. ja v a 2 s . co m*/ Stack stack = null; try { stack = findStack(); } catch (final Exception e) { return newStackWithStatus(StackStatus.CREATE_FAILED, e.toString()); } if (!isStackValid(stack)) { return newStackWithStatus(StackStatus.CREATE_FAILED, "stack create invalid/missing"); } final StackStatus status = StackStatus.fromValue(stack.getStackStatus()); switch (status) { case CREATE_IN_PROGRESS: final long timeCurrent = System.currentTimeMillis(); final long timeDiff = timeCurrent - timeStart; logger.info("stack create in progress; time=" + timeDiff / 1000); sleep(); continue; case CREATE_COMPLETE: logger.info("stack create success"); printStackEvents(); return stack; default: logger.error("stack create failure"); return stack; } } }
From source file:jetbrains.buildServer.runner.cloudformation.AWSClient.java
License:Apache License
public void waitForCompletion(AmazonCloudFormationClient stackbuilder, String stackName) throws InterruptedException { DescribeStacksRequest wait = new DescribeStacksRequest(); wait.setStackName(stackName);/*w w w. jav a2 s . com*/ Boolean completed = false; String action = "CREATE"; String stackStatus = "Waiting"; String stackReason = ""; String stackId = ""; List<String> events; int len, first, last; first = 0; myListener.waitForStack(stackStatus); while (!completed) { List<Stack> stacks = stackbuilder.describeStacks(wait).getStacks(); if (stacks.isEmpty()) { completed = true; stackStatus = "NO_SUCH_STACK"; stackReason = "Stack has been deleted"; } else { for (Stack stack : stacks) { if (stack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString()) || stack.getStackStatus().equals(StackStatus.CREATE_FAILED.toString()) || stack.getStackStatus().equals(StackStatus.ROLLBACK_FAILED.toString()) || stack.getStackStatus().equals(StackStatus.DELETE_FAILED.toString())) { completed = true; stackStatus = stack.getStackStatus(); if (stack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString())) { stackReason = "Success"; } else { stackReason = "Failure"; } stackId = stack.getStackId(); } } } //sleep for 10 seconds Thread.sleep(10000); } if (completed) { events = describeStackEvents(stackbuilder, stackName, action); for (String event : events) { myListener.waitForStack(event.toString()); } events.clear(); } myListener.waitForStack(stackStatus); if (stackReason.contains("Failure")) { myListener.createStackFailed(stackName, stackStatus, stackReason); } else { myListener.createStackFinished(stackName, stackStatus); } }
From source file:org.springframework.cloud.stream.app.aws.AwsIntegrationTestStackRule.java
License:Apache License
private void waitForCompletion() throws InterruptedException { DescribeStacksRequest wait = new DescribeStacksRequest(); wait.setStackName(this.stackName); Boolean completed = false;/*from w w w . jav a 2s. c o m*/ String stackStatus = "Unknown"; String stackReason = ""; while (!completed) { List<Stack> stacks = null; try { stacks = this.cloudFormation.describeStacks(wait).getStacks(); } catch (Exception e) { logger.error("cloudFormation.describeStacks() exception", e); } if (CollectionUtils.isEmpty(stacks)) { completed = true; stackStatus = StackStatus.DELETE_COMPLETE.toString(); stackReason = "Stack has been deleted"; } else { for (Stack stack : stacks) { if (stack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString()) || stack.getStackStatus().equals(StackStatus.CREATE_FAILED.toString()) || stack.getStackStatus().equals(StackStatus.ROLLBACK_FAILED.toString()) || stack.getStackStatus().equals(StackStatus.DELETE_FAILED.toString())) { completed = true; stackStatus = stack.getStackStatus(); stackReason = stack.getStackStatusReason(); } } } // Not done yet so sleep for 2 seconds. if (!completed) { Thread.sleep(2000); } else { if (stackStatus.equals(StackStatus.CREATE_FAILED.toString())) { Assume.assumeTrue( "The test AWS stack [" + this.stackName + "] cannot be created. Reason: " + stackReason, true); } } } }
From source file:org.terracotta.TerracottaCloudFormationSample.java
License:Open Source License
public static String waitForCompletion(AmazonCloudFormation stackbuilder, String stackName) throws Exception { DescribeStacksRequest wait = new DescribeStacksRequest(); wait.setStackName(stackName);//from w w w . j ava 2s . c o m Boolean completed = false; String stackStatus = "Unknown"; String stackReason = ""; System.out.print("Waiting"); while (!completed) { List<Stack> stacks = stackbuilder.describeStacks(wait).getStacks(); if (stacks.isEmpty()) { completed = true; stackStatus = "NO_SUCH_STACK"; stackReason = "Stack has been deleted"; } else { for (Stack stack : stacks) { if (stack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString()) || stack.getStackStatus().equals(StackStatus.CREATE_FAILED.toString()) || stack.getStackStatus().equals(StackStatus.ROLLBACK_FAILED.toString()) || stack.getStackStatus().equals(StackStatus.DELETE_FAILED.toString())) { completed = true; stackStatus = stack.getStackStatus(); stackReason = stack.getStackStatusReason(); } } } // Show we are waiting System.out.print("."); // Not done yet so sleep for 30 seconds. if (!completed) Thread.sleep(30000); } // Show we are done System.out.print("done\n"); return stackStatus + " (" + stackReason + ")"; }