Java Code Examples for com.amazonaws.services.cloudformation.AmazonCloudFormation#describeStacks()
The following examples show how to use
com.amazonaws.services.cloudformation.AmazonCloudFormation#describeStacks() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AWSProvider.java From testgrid with Apache License 2.0 | 6 votes |
private static Properties getCloudformationOutputs(AmazonCloudFormation cloudFormation, CreateStackResult stack) { DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest(); describeStacksRequest.setStackName(stack.getStackId()); final DescribeStacksResult describeStacksResult = cloudFormation .describeStacks(describeStacksRequest); Properties outputProps = new Properties(); for (Stack st : describeStacksResult.getStacks()) { StringBuilder outputsStr = new StringBuilder("Infrastructure/Deployment outputs {\n"); for (Output output : st.getOutputs()) { outputProps.setProperty(output.getOutputKey(), output.getOutputValue()); outputsStr.append(output.getOutputKey()).append("=").append(output.getOutputValue()).append("\n"); } //Log cfn outputs logger.info(outputsStr.toString() + "\n}"); } return outputProps; }
Example 2
Source File: InventoryUtil.java From pacbot with Apache License 2.0 | 5 votes |
/** * Fetch cloud formation stack. * * @param temporaryCredentials the temporary credentials * @param skipRegions the skip regions * @param accountId the accountId * @param accountName the account name * @return the map */ public static Map<String,List<Stack>> fetchCloudFormationStack(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){ AmazonCloudFormation cloudFormClient ; Map<String,List<Stack>> stacks = new LinkedHashMap<>(); String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"Stack\" , \"region\":\"" ; for(Region region : RegionUtils.getRegions()){ try{ if(!skipRegions.contains(region.getName())){ List<Stack> stacksTemp = new ArrayList<>(); String nextToken = null; cloudFormClient = AmazonCloudFormationClientBuilder.standard(). withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build(); DescribeStacksResult describeResult ; do{ describeResult = cloudFormClient.describeStacks(new DescribeStacksRequest().withNextToken(nextToken)); stacksTemp.addAll(describeResult.getStacks()); nextToken = describeResult.getNextToken(); }while(nextToken!=null); if(! stacksTemp.isEmpty() ){ log.debug(InventoryConstants.ACCOUNT + accountId +" Type : Cloud Formation Stack "+region.getName() + " >> " + stacksTemp.size()); stacks.put(accountId+delimiter+accountName+delimiter+region.getName(), stacksTemp); } } }catch(Exception e){ log.warn(expPrefix+ region.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,region.getName(),"stack",e.getMessage()); } } return stacks; }
Example 3
Source File: CloudFormationUtils.java From amazon-kinesis-connectors with Apache License 2.0 | 5 votes |
private static boolean stackExists(AmazonCloudFormation client, String stackName) { DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest(); describeStacksRequest.setStackName(stackName); try { client.describeStacks(describeStacksRequest); return true; } catch (AmazonServiceException e) { return false; } }