@Override
public StackDescription describeStackWithResources(Stack stack, Credential credential) {
MDCBuilder.buildMdcContext(stack);
AwsTemplate awsInfra = (AwsTemplate) stack.getTemplate();
AwsCredential awsCredential = (AwsCredential) credential;
DescribeStacksResult stackResult = null;
DescribeStackResourcesResult resourcesResult = null;
DescribeInstancesResult instancesResult = null;
Resource resource = stack.getResourceByType(ResourceType.CLOUDFORMATION_STACK);
if (resource != null) {
try {
AmazonCloudFormationClient client = awsStackUtil.createCloudFormationClient(awsInfra.getRegion(), awsCredential);
DescribeStacksRequest stackRequest = new DescribeStacksRequest().withStackName(
resource.getResourceName()
);
stackResult = client.describeStacks(stackRequest);
DescribeStackResourcesRequest resourcesRequest = new DescribeStackResourcesRequest().withStackName(
resource.getResourceName()
);
resourcesResult = client.describeStackResources(resourcesRequest);
} catch (AmazonServiceException e) {
if (CF_SERVICE_NAME.equals(e.getServiceName())
&& e.getErrorMessage().equals(String.format("Stack:%s does not exist",
resource.getResourceName()))) {
LOGGER.error("Amazon CloudFormation stack {} doesn't exist. Returning null in describeStack.",
resource.getResourceName());
stackResult = new DescribeStacksResult();
} else {
throw e;
}
}
try {