List of usage examples for com.amazonaws.services.cloudformation AmazonCloudFormationClient createStack
@Override
public CreateStackResult createStack(CreateStackRequest request)
Creates a stack as specified in the template.
From source file:com.tvarit.plugin.StackMaker.java
License:Open Source License
public Stack makeStack(CreateStackRequest createStackRequest, AmazonCloudFormationClient amazonCloudFormationClient, Log log) throws MojoFailureException { CreateStackResult createStackResult = amazonCloudFormationClient.createStack(createStackRequest); final String stackName = createStackRequest.getStackName(); DescribeStacksResult describeStacksResult = amazonCloudFormationClient .describeStacks(new DescribeStacksRequest().withStackName(stackName)); while (describeStacksResult.getStacks().get(0).getStackStatus() .equals(StackStatus.CREATE_IN_PROGRESS.toString())) { try {/* w w w .j a v a 2s .c o m*/ log.info("Awaiting stack create completion!"); Thread.sleep(5000); } catch (InterruptedException e) { log.error(e); throw new RuntimeException(e); } describeStacksResult = amazonCloudFormationClient .describeStacks(new DescribeStacksRequest().withStackName(stackName)); } final Stack stack = describeStacksResult.getStacks().get(0); final String stackStatus = stack.getStackStatus(); if (!stackStatus.equals(StackStatus.CREATE_COMPLETE.toString())) { throw new MojoFailureException("Could not create infrastructure. Stack Status is: " + stackStatus + ". Please review details on the AWS console and open a new github issue on https://github.com/sdole/tvarit-maven/issues/new that is needed."); } return stack; }