Example usage for com.amazonaws.services.cloudformation.model DescribeStackEventsRequest withStackName

List of usage examples for com.amazonaws.services.cloudformation.model DescribeStackEventsRequest withStackName

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudformation.model DescribeStackEventsRequest withStackName.

Prototype


public DescribeStackEventsRequest withStackName(String stackName) 

Source Link

Document

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.

    Usage

    From source file:com.carrotgarden.maven.aws.cfn.CarrotCloudForm.java

    License:BSD License

    private void printStackEvents() {
    
        final DescribeStackEventsRequest request = new DescribeStackEventsRequest();
    
        request.withStackName(name);
    
        final DescribeStackEventsResult describeStackEvents = amazonClient.describeStackEvents(request);
    
        final List<StackEvent> stackEvents = describeStackEvents.getStackEvents();
    
        Collections.reverse(stackEvents);
    
        logger.info("stack events:");
    
        for (final StackEvent event : stackEvents) {
    
            final StringBuilder text = new StringBuilder(128);
    
            text.append("\n\t");
            text.append("time=");
            text.append(event.getTimestamp());
    
            text.append("\n\t");
            text.append("id=");
            text.append(event.getEventId());
    
            text.append("\n\t");
            text.append("type=");
            text.append(event.getResourceType());
    
            text.append("\n\t");
            text.append("status=");
            text.append(event.getResourceStatus());
    
            text.append("\n\t");
            text.append("reason=");
            text.append(event.getResourceStatusReason());
    
            logger.info("event {}", text);
    
        }//from ww  w .j  a va  2s. com
    
    }
    

    From source file:io.konig.maven.CreateCloudFormationStackAction.java

    License:Apache License

    private List<Output> getOutputForRequest(String stackName, AmazonCloudFormation client)
            throws InterruptedException, StackCreationException {
        int tried = 0;
        String maxTime = System.getProperty("stackMaxTime");
        while (tried < (maxTime == null ? 1800 : Integer.parseInt(maxTime))) {
            DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest();
            describeStacksRequest.withStackName(stackName);
            Stack resultStack = client.describeStacks(describeStacksRequest).getStacks().get(0);
            StackStatus stackStatus = StackStatus.valueOf(resultStack.getStackStatus());
            if (("CREATE_COMPLETE").equals(stackStatus.toString())) {
                return resultStack.getOutputs();
            } else if (stackStatus.toString().endsWith("IN_PROGRESS")) {
                Thread.sleep(10000);//  w ww.j  a v a  2s .c  om
            } else {
                DescribeStackEventsRequest describeStackEventsRequest = new DescribeStackEventsRequest();
                describeStackEventsRequest.withStackName(stackName);
                List<StackEvent> stackEvents = client.describeStackEvents(describeStackEventsRequest)
                        .getStackEvents();
                List<StackEvent> errorEvents = new ArrayList<StackEvent>();
                for (StackEvent stackEvent : stackEvents) {
                    if (stackEvent.getResourceStatus().equals("CREATE_FAILED")) {
                        errorEvents.add(stackEvent);
                    }
                }
                throw new StackCreationException(errorEvents.toString());
            }
            tried++;
        }
        throw new RuntimeException("stack creation/deletion timed out");
    }