Example usage for com.amazonaws.services.cloudformation.model Stack getCreationTime

List of usage examples for com.amazonaws.services.cloudformation.model Stack getCreationTime

Introduction

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

Prototype


public java.util.Date getCreationTime() 

Source Link

Document

The time at which the stack was created.

Usage

From source file:com.haskins.cloudtrailviewer.dialog.resourcedetail.detailpanels.CfStackDetail.java

License:Open Source License

private void buildUI(DescribeStacksResult detail) {

    JTabbedPane tabs = new JTabbedPane();
    tabs.add("Stack", primaryScrollPane);

    final JTable outputCheckTable = new JTable(outputTableModel);
    JScrollPane healthCheckScrollPane = new JScrollPane(outputCheckTable);
    tabs.add("Output", healthCheckScrollPane);

    final JTable paramsTable = new JTable(parametersTableModel);
    JScrollPane listenersScrollPane = new JScrollPane(paramsTable);
    tabs.add("Parameters", listenersScrollPane);

    this.add(tabs, BorderLayout.CENTER);

    if (!detail.getStacks().isEmpty()) {

        List<Stack> stacks = detail.getStacks();
        Stack stack = stacks.get(0);

        if (stack.getCreationTime() != null) {
            primaryTableModel.addRow(new Object[] { "Created", getDateString(stack.getCreationTime()) });
        }/*  www .ja  v  a 2  s  .  c  o m*/
        if (stack.getDescription() != null) {
            primaryTableModel.addRow(new Object[] { "Description", stack.getDescription() });
        }
        if (stack.getDisableRollback() != null) {
            primaryTableModel.addRow(new Object[] { "Disable Rollback", stack.getDisableRollback() });
        }
        if (stack.getLastUpdatedTime() != null) {
            primaryTableModel
                    .addRow(new Object[] { "Last Updated", getDateString(stack.getLastUpdatedTime()) });
        }
        if (stack.getNotificationARNs() != null) {
            primaryTableModel.addRow(new Object[] { "Notification Arns", stack.getNotificationARNs() });
        }
        if (stack.getStackId() != null) {
            primaryTableModel.addRow(new Object[] { "Stacks Id", stack.getStackId() });
        }
        if (stack.getStackName() != null) {
            primaryTableModel.addRow(new Object[] { "Stacks Name", stack.getStackName() });
        }
        if (stack.getStackStatus() != null) {
            primaryTableModel.addRow(new Object[] { "Stacks Status", stack.getStackStatus() });
        }
        if (stack.getStackStatusReason() != null) {
            primaryTableModel.addRow(new Object[] { "Stacks Status Reason", stack.getStackStatusReason() });
        }
        if (stack.getTimeoutInMinutes() != null) {
            primaryTableModel.addRow(new Object[] { "Timeout (minutes)", stack.getTimeoutInMinutes() });
        }

        /**
         * Tags
         */
        List<Tag> tags = stack.getTags();
        for (Tag tag : tags) {
            tagsTableModel.addRow(new Object[] { tag.getKey(), tag.getValue() });
        }

        /**
         * Output
         */
        outputTableModel.addColumn("Description");
        outputTableModel.addColumn("Key");
        outputTableModel.addColumn("Value");

        List<Output> outputs = stack.getOutputs();
        for (Output output : outputs) {
            tagsTableModel.addRow(
                    new Object[] { output.getDescription(), output.getOutputKey(), output.getOutputValue() });
        }

        /**
         * Parameters
         */
        parametersTableModel.addColumn("Key");
        parametersTableModel.addColumn("Value");
        parametersTableModel.addColumn("User Previous Value");

        List<Parameter> parameters = stack.getParameters();
        for (Parameter parameter : parameters) {
            tagsTableModel.addRow(new Object[] { parameter.getParameterKey(), parameter.getParameterValue(),
                    parameter.getUsePreviousValue() });
        }
    }
}

From source file:com.netflix.spinnaker.clouddriver.aws.provider.agent.AmazonCloudFormationCachingAgent.java

License:Apache License

@Override
public CacheResult loadData(ProviderCache providerCache) {
    log.info("Describing items in {}", getAgentType());
    AmazonCloudFormation cloudformation = amazonClientProvider.getAmazonCloudFormation(account, region);

    Collection<CacheData> stackCacheData = new ArrayList<>();

    try {//  w  w w .  j a va 2  s. c o  m
        List<Stack> stacks = cloudformation.describeStacks().getStacks();

        for (Stack stack : stacks) {
            Map<String, Object> stackAttributes = new HashMap<>();
            stackAttributes.put("stackId", stack.getStackId());
            stackAttributes.put("tags",
                    stack.getTags().stream().collect(Collectors.toMap(Tag::getKey, Tag::getValue)));
            stackAttributes.put("outputs", stack.getOutputs().stream()
                    .collect(Collectors.toMap(Output::getOutputKey, Output::getOutputValue)));
            stackAttributes.put("stackName", stack.getStackName());
            stackAttributes.put("region", region);
            stackAttributes.put("accountName", account.getName());
            stackAttributes.put("accountId", account.getAccountId());
            stackAttributes.put("stackStatus", stack.getStackStatus());
            stackAttributes.put("creationTime", stack.getCreationTime());

            if (stack.getStackStatus().equals("ROLLBACK_COMPLETE")) {
                DescribeStackEventsRequest request = new DescribeStackEventsRequest()
                        .withStackName(stack.getStackName());
                cloudformation.describeStackEvents(request).getStackEvents().stream()
                        .filter(e -> e.getResourceStatus().equals("CREATE_FAILED")).findFirst()
                        .map(StackEvent::getResourceStatusReason)
                        .map(statusReason -> stackAttributes.put("stackStatusReason", statusReason));
            }
            String stackCacheKey = Keys.getCloudFormationKey(stack.getStackId(), region, account.getName());
            Map<String, Collection<String>> relationships = new HashMap<>();
            relationships.put(STACKS.getNs(), Collections.singletonList(stackCacheKey));
            stackCacheData.add(new DefaultCacheData(stackCacheKey, stackAttributes, relationships));
        }
    } catch (AmazonCloudFormationException e) {
        log.error("Error retrieving stacks", e);
    }

    log.info("Caching {} items in {}", stackCacheData.size(), getAgentType());
    HashMap<String, Collection<CacheData>> result = new HashMap<>();
    result.put(STACKS.getNs(), stackCacheData);
    return new DefaultCacheResult(result);
}

From source file:org.xmlsh.aws.cfnDescribeStacks.java

License:BSD License

private void writeStack(Stack stack) throws XMLStreamException {
    startElement("stack");
    attribute("creation-time", stack.getCreationTime());
    attribute("description", stack.getDescription());
    attribute("disable-rollback", stack.getDisableRollback());
    attribute("last-update-time", stack.getLastUpdatedTime());
    attribute("stack-id", stack.getStackId());
    attribute("stack-name", stack.getStackName());
    attribute("stack-status", stack.getStackStatus());
    attribute("stack-status-reason", stack.getStackStatusReason());
    attribute("timeout", stack.getTimeoutInMinutes());

    writeParameters(stack.getParameters());
    writeOutputs(stack.getOutputs());/*from  ww  w  .  ja v  a  2 s  . c  o m*/
    writeCapibilities(stack.getCapabilities());
    writeNotifications(stack.getNotificationARNs());
    writeTags(stack.getTags());
}