List of usage examples for com.amazonaws.services.cloudformation.model DescribeStacksRequest setStackName
public void setStackName(String stackName)
The name or the unique stack ID that is associated with the stack, which are not always interchangeable:
Running stacks: You can specify either the stack's name or its unique stack ID.
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); Boolean completed = false;/*from w ww .j a v a2 s . c o m*/ 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:com.cleanenergyexperts.aws.cf.CloudFormationMojo.java
License:Apache License
protected Stack getStack(AmazonCloudFormationClient cfClient, String stackName) throws MojoExecutionException { Stack stack = null;//from w w w . j a v a 2 s. co m try { DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest(); describeStacksRequest.setStackName(stackName); getLog().info("Getting Cloud Formation Stack Details..."); DescribeStacksResult describeStacksResult = cfClient.describeStacks(describeStacksRequest); if (describeStacksResult == null || describeStacksResult.getStacks() == null || describeStacksResult.getStacks().isEmpty()) { throw new MojoExecutionException("[NULL] Could Not Get Cloud Formation Stack Details"); } stack = describeStacksResult.getStacks().get(0); } catch (AmazonServiceException e) { throw new MojoExecutionException("[SERVICE] Could Not Get Cloud Formation Stack Details", e); } catch (AmazonClientException e) { throw new MojoExecutionException("[CLIENT] Could Not Get Cloud Formation Stack Details", e); } return stack; }
From source file:com.haskins.cloudtrailviewer.dialog.resourcedetail.detailpanels.CfStackDetail.java
License:Open Source License
@Override public String retrieveDetails(ResourceDetailRequest detailRequest) { String response = null;//from ww w .ja va 2 s . c o m try { AmazonCloudFormation client = new AmazonCloudFormationClient(credentials); client.setRegion(Region.getRegion(Regions.fromName(detailRequest.getRegion()))); DescribeStacksRequest request = new DescribeStacksRequest(); request.setStackName(detailRequest.getResourceName()); DescribeStacksResult result = client.describeStacks(request); buildUI(result); } catch (IllegalArgumentException | AmazonClientException e) { response = e.getMessage(); LOGGER.log(Level.WARNING, "Problem retrieving CloudFormation details from AWS", e); } return response; }
From source file:com.kinesisboard.amazonaws.utils.CloudFormationUtils.java
License:Open Source License
private static boolean stackExists(AmazonCloudFormation client, String stackName) { DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest(); describeStacksRequest.setStackName(stackName); try {/* w ww . ja va 2 s. co m*/ client.describeStacks(describeStacksRequest); return true; } catch (AmazonServiceException e) { return false; } }
From source file:com.kinesisboard.amazonaws.utils.CloudFormationUtils.java
License:Open Source License
private static StackStatus stackStatus(AmazonCloudFormation client, String stackName) { DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest(); describeStacksRequest.setStackName(stackName); // describeStacks (with stack name specified) will return list of size 1 if found // and throw AmazonServiceException if no stack with that name exists try {//from ww w .j a v a 2 s .c o m return StackStatus .fromValue(client.describeStacks(describeStacksRequest).getStacks().get(0).getStackStatus()); } catch (AmazonServiceException ase) { return null; } }
From source file:com.mweagle.tereus.aws.CloudFormation.java
License:Open Source License
protected Optional<DescribeStacksResult> describeStack(final AmazonCloudFormationAsyncClient awsClient, final String stackName, Logger logger) throws Exception { final DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest(); describeStacksRequest.setStackName(stackName); return Optional.of(awsClient.describeStacks(describeStacksRequest)); }
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); Boolean completed = false;/*from ww w. j a v a2 s . c o m*/ 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:jetbrains.buildServer.runner.cloudformation.AWSClient.java
License:Apache License
public void waitForDelete(AmazonCloudFormationClient stackbuilder, String stackName) throws InterruptedException { DescribeStacksRequest wait = new DescribeStacksRequest(); wait.setStackName(stackName); String stackStatus;/* w w w . j a va 2s. c o m*/ String stackReason; String action = "DELETE"; Boolean delete = false; List<String> events; while (!delete) { List<Stack> stacks = stackbuilder.describeStacks(wait).getStacks(); if (stacks.isEmpty()) { delete = true; stackStatus = "NO_SUCH_STACK"; stackReason = "Stack has been deleted"; } else { myListener.debugLog("From the wait for delete"); events = describeStackEvents(stackbuilder, stackName, action); for (String event : events) { myListener.waitForStack(event.toString()); } Thread.sleep(10000); events.clear(); } } stackStatus = "done"; stackReason = "Delete Complete"; myListener.waitForStack(stackStatus); myListener.createStackFinished(stackName, stackStatus); }
From source file:jetbrains.buildServer.runner.cloudformation.AWSClient.java
License:Apache License
public Boolean isStackExists(@NotNull String stackName) { Boolean exists;/*from w w w . jav a 2 s . c om*/ DescribeStacksRequest wait = new DescribeStacksRequest(); wait.setStackName(stackName); return true; }
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;/*w w w.j a v a 2 s.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); } } } }