in src/main/java/com/awslabs/aws/greengrass/provisioner/implementations/helpers/BasicCloudFormationHelper.java [111:142]
public void waitForStackToLaunch(String stackName) {
DescribeStacksRequest describeStacksRequest = DescribeStacksRequest.builder()
.stackName(stackName)
.build();
DescribeStacksResponse describeStacksResponse = cloudFormationClient.describeStacks(describeStacksRequest);
StackStatus stackStatus = describeStacksResponse.stacks().get(0).stackStatus();
while (stackStatus.equals(StackStatus.CREATE_IN_PROGRESS) ||
stackStatus.equals(StackStatus.UPDATE_IN_PROGRESS)) {
if (stackStatus.equals(StackStatus.ROLLBACK_IN_PROGRESS) ||
(stackStatus.equals(StackStatus.ROLLBACK_COMPLETE)) ||
(stackStatus.equals(StackStatus.ROLLBACK_FAILED))) {
throw new RuntimeException(String.join("", "CloudFormation stack [", stackName, "] failed to launch"));
}
String action = "creating";
if (stackStatus.equals(StackStatus.UPDATE_IN_PROGRESS)) {
action = "updating";
}
log.info(String.join("", "Waiting for stack to finish ", action, " [", stackName, ", ", stackStatus.toString(), "]..."));
ioHelper.sleep(10000);
describeStacksResponse = cloudFormationClient.describeStacks(describeStacksRequest);
stackStatus = describeStacksResponse.stacks().get(0).stackStatus();
}
log.info(String.join("", "CloudFormation stack ready [", stackName, "]"));
}