List of usage examples for com.amazonaws.services.cloudformation.model Stack getTags
public java.util.List<Tag> getTags()
A list of Tags that specify information about the stack.
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()) }); }/*from w ww . j a v a 2 s. co 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.mweagle.tereus.commands.pipelines.UpdatePipeline.java
License:Open Source License
protected void publishGlobals(ScriptEngine engine) { super.publishGlobals(engine); // Publish a function that accepts a stack target name, defined by the patch // file, that represents the target. We'll push all this Function<String, String> fnStackInfo = (stackName) -> { // Get the information... final GetTemplateRequest templateRequest = new GetTemplateRequest().withStackName(stackName); final AmazonCloudFormationAsyncClient awsClient = new AmazonCloudFormationAsyncClient( super.getAwsCredentials()); awsClient.setRegion(super.getRegion()); final GetTemplateResult stackTemplateResult = awsClient.getTemplate(templateRequest); // Get the stack info and return it final DescribeStacksRequest describeRequest = new DescribeStacksRequest().withStackName(stackName); final DescribeStacksResult describeResult = awsClient.describeStacks(describeRequest); // And finally the tags and parameters final Stack stackInfo = !describeResult.getStacks().isEmpty() ? describeResult.getStacks().get(0) : null;//from www . ja v a2 s .co m final Map<String, Object> tags = (stackInfo != null) ? stackInfo.getTags().stream().collect(Collectors.toMap(Tag::getKey, Tag::getValue)) : Collections.emptyMap(); final Map<String, Object> params = (stackInfo != null) ? stackInfo.getParameters().stream() .collect(Collectors.toMap(Parameter::getParameterKey, Parameter::getParameterValue)) : Collections.emptyMap(); HashMap<String, Object> results = new HashMap<>(); results.put("tags", tags); results.put("params", params); results.put("stack", stackInfo); results.put("template", stackTemplateResult.getTemplateBody().toString()); Gson gson = new Gson(); return gson.toJson(results); }; engine.put("TargetStackInfoImpl", fnStackInfo); Supplier<String> fnArgs = () -> { HashMap<String, Map<String, Object>> args = new HashMap<>(); args.put("arguments", this.arguments); Gson gson = new Gson(); return gson.toJson(args); }; engine.put("ArgumentsImpl", fnArgs); }
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 {/*from w w w . j a v a2s .co 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.springframework.cloud.aws.core.env.stack.config.StackResourceUserTagsFactoryBean.java
License:Apache License
@Override protected Map<String, String> createInstance() throws Exception { LinkedHashMap<String, String> userTags = new LinkedHashMap<>(); DescribeStacksResult stacksResult = this.amazonCloudFormation .describeStacks(new DescribeStacksRequest().withStackName(this.stackNameProvider.getStackName())); for (Stack stack : stacksResult.getStacks()) { for (Tag tag : stack.getTags()) { userTags.put(tag.getKey(), tag.getValue()); }//from w w w.ja va2s .co m } return userTags; }
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 va 2 s .c o m writeCapibilities(stack.getCapabilities()); writeNotifications(stack.getNotificationARNs()); writeTags(stack.getTags()); }