Java Code Examples for com.amazonaws.services.cloudformation.model.Stack#getOutputs()

The following examples show how to use com.amazonaws.services.cloudformation.model.Stack#getOutputs() . 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: CloudFormationClient.java    From herd-mdl with Apache License 2.0 6 votes vote down vote up
/**
 * Get outputs for the wrapper stack and all nested stacks
 *
 * @return Outputs for stack {@link #stackName}
 */

public Map<String, String> getStackOutput() throws Exception {

    String rootStackId = getStackInfo().stackId();
    LOGGER.info("rootStackId   =   " + rootStackId);
    Map<String, String> outputs = new HashMap<>();
    outputs.put("rootStackId", rootStackId);

    DescribeStacksResult describeStacksResult = amazonCloudFormation.describeStacks();
    for (Stack currentStack : describeStacksResult.getStacks()) {
        // Get the output details for the running stacks that got created
        // go through both root and nested stacks
        if (currentStack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString())
                && (rootStackId.equals(currentStack.getRootId())
                || rootStackId.equals(currentStack.getStackId()))) {
            for (Output output : currentStack.getOutputs()) {
                LOGGER.info(output.getOutputKey() + "   =   " + output.getOutputValue());
                outputs.put(output.getOutputKey(), output.getOutputValue());
            }
        }
    }
    return outputs;
}
 
Example 2
Source File: AWSProvider.java    From testgrid with Apache License 2.0 6 votes vote down vote up
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 3
Source File: CloudFormationStack.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: TestStackInstanceIdService.java    From spring-cloud-aws with Apache License 2.0 5 votes vote down vote up
private static String getOutputValue(Stack stack, String outputKey) {
	for (Output output : stack.getOutputs()) {
		if (output.getOutputKey().equals(outputKey)) {
			return output.getOutputValue();
		}
	}

	throw new IllegalStateException("No output '" + outputKey
			+ "' defined in stack '" + stack.getStackName() + "'");
}