Search in sources :

Example 1 with Stack

use of com.amazonaws.services.cloudformation.model.Stack in project pipeline-aws-plugin by jenkinsci.

the class CloudFormationStack method describeOutputs.

public Map<String, String> describeOutputs() {
    DescribeStacksResult result = this.client.describeStacks(new DescribeStacksRequest().withStackName(this.stack));
    Stack cfnStack = result.getStacks().get(0);
    Map<String, String> map = new HashMap<>();
    for (Output output : cfnStack.getOutputs()) {
        map.put(output.getOutputKey(), output.getOutputValue());
    }
    return map;
}
Also used : DescribeStacksRequest(com.amazonaws.services.cloudformation.model.DescribeStacksRequest) HashMap(java.util.HashMap) Output(com.amazonaws.services.cloudformation.model.Output) DescribeStacksResult(com.amazonaws.services.cloudformation.model.DescribeStacksResult) Stack(com.amazonaws.services.cloudformation.model.Stack)

Example 2 with Stack

use of com.amazonaws.services.cloudformation.model.Stack in project cloudbreak by hortonworks.

the class AwsCreateVpcNetworkTest method getOutputForRequest.

private List<Output> getOutputForRequest(String vpcStackName, AmazonCloudFormation client) {
    int tried = 0;
    while (tried < MAX_TRY) {
        LOGGER.info("checking vpc stack creation result, tried: " + tried + '/' + MAX_TRY);
        DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest();
        describeStacksRequest.withStackName(vpcStackName);
        Stack resultStack = client.describeStacks(describeStacksRequest).getStacks().get(0);
        StackStatus stackStatus = StackStatus.valueOf(resultStack.getStackStatus());
        if (FAILED_STATUSES.contains(stackStatus)) {
            LOGGER.error("stack creation failed: {}", stackStatus);
            throw new RuntimeException();
        } else if (CREATE_COMPLETE.equals(stackStatus)) {
            return resultStack.getOutputs();
        }
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            LOGGER.error("thread sleep interrupted", e);
        }
        tried++;
    }
    throw new RuntimeException("vpc creation timed out");
}
Also used : DescribeStacksRequest(com.amazonaws.services.cloudformation.model.DescribeStacksRequest) StackStatus(com.amazonaws.services.cloudformation.model.StackStatus) Stack(com.amazonaws.services.cloudformation.model.Stack)

Example 3 with Stack

use of com.amazonaws.services.cloudformation.model.Stack in project cloudbreak by hortonworks.

the class AbstractAwsStackStatusCheckerTask method doCall.

@Override
protected Boolean doCall() {
    LOGGER.info("Checking if AWS CloudFormation stack '{}' reached status '{}'", cloudFormationStackName, successStatus);
    try {
        com.amazonaws.services.cloudformation.model.Stack cfStack = cfClient.describeStacks(describeStacksRequest).getStacks().get(0);
        List<StackEvent> stackEvents = cfClient.describeStackEvents(stackEventsRequest).getStackEvents();
        return doCheck(cfStack, stackEvents);
    } catch (AmazonServiceException e) {
        return handleError(e);
    }
}
Also used : StackEvent(com.amazonaws.services.cloudformation.model.StackEvent) AmazonServiceException(com.amazonaws.AmazonServiceException) Stack(com.amazonaws.services.cloudformation.model.Stack)

Aggregations

Stack (com.amazonaws.services.cloudformation.model.Stack)3 DescribeStacksRequest (com.amazonaws.services.cloudformation.model.DescribeStacksRequest)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 DescribeStacksResult (com.amazonaws.services.cloudformation.model.DescribeStacksResult)1 Output (com.amazonaws.services.cloudformation.model.Output)1 StackEvent (com.amazonaws.services.cloudformation.model.StackEvent)1 StackStatus (com.amazonaws.services.cloudformation.model.StackStatus)1 HashMap (java.util.HashMap)1