private void verifyPreviousCommandCompletion()

in TerraformCustomResourceHandler/src/main/java/com/amazon/servicecatalog/terraform/customresource/fulfillment/CommandSender.java [129:153]


    private void verifyPreviousCommandCompletion() {
        TerraformCommandRecord record = commandRecordPersistence.getCommandRecord(request.getPhysicalResourceId());
        // no concurrent command exists
        if (record == null) {
            return;
        }

        String commandId = record.getCommandId();
        String instanceId = record.getInstanceId();

        try {
            GetCommandInvocationResult commandResult = ssmFacade.getCommand(commandId, instanceId);

            if (EXECUTING_COMMAND_STATUS.contains(commandResult.getStatus())) {
                String message = String.format("SSM is still executing a Terraform command for this stack. Command " +
                                "ID: %s. Instance Id: %s.", commandId, instanceId);
                ResponsePoster.postFailure(request, message);
            }
        } catch (InvocationDoesNotExistException e) {
            String message = String.format("A command record was found, but no invocation exists for InstanceId ID " +
                    "%s with CommandId %s. Beginning command execution with the assumption that the previous command " +
                    "has completed and expired.", instanceId, commandId);
            log.warn(message);
        }
    }