public async runTerraformTests()

in src/cloudShell.ts [76:124]


    public async runTerraformTests(testType: string, workingDirectory: string) {
        if (await this.connectedToCloudShell()) {

            const workspaceName: string = path.basename(workingDirectory);
            const setupFilesFolder: string = `${workspaceName}/.TFTesting`;
            const localPath: string = path.join(workingDirectory, ".TFTesting");
            const createAciScript: string = "createacitest.sh";
            const containerCommandScript: string = "containercmd.sh";
            const resourceGroup: string = settingUtils.getResourceGroupForTest();
            const aciName: string = settingUtils.getAciNameForTest();
            const aciGroup: string = settingUtils.getAciGroupForTest();

            const tfConfiguration = escapeFile(aciConfig(
                resourceGroup,
                aciName,
                aciGroup,
                this.storageAccountName,
                this.fileShareName,
                settingUtils.getLocationForTest(),
                settingUtils.getImageNameForTest(),
                workspaceName,
            ));

            const shellscript = exportTestScript(tfConfiguration, this.resourceGroup, this.storageAccountName, setupFilesFolder);

            await Promise.all([
                fsExtra.outputFile(path.join(localPath, createAciScript), shellscript),
                fsExtra.outputFile(path.join(localPath, containerCommandScript), exportContainerCmd(workspaceName, await this.resolveContainerCmd(testType))),
            ]);

            await Promise.all([
                azFilePush(workspaceName, this.storageAccountName, this.storageAccountKey, this.fileShareName, path.join(localPath, createAciScript)),
                azFilePush(workspaceName, this.storageAccountName, this.storageAccountKey, this.fileShareName, path.join(localPath, containerCommandScript)),
            ]);

            await vscode.commands.executeCommand("azureTerraform.push");

            const sentToTerminal: boolean = await this.runTFCommand(
                `source ${createAciScript} && terraform fmt && terraform init && terraform apply -auto-approve && terraform taint azurerm_container_group.TFTest && \
                echo "\nRun the following command to get the logs from the ACI container: az container logs -g ${resourceGroup} -n ${aciGroup}\n"`,
                `${Constants.clouddrive}/${setupFilesFolder}`,
            );
            if (sentToTerminal) {
                vscode.window.showInformationMessage(`An Azure Container Instance will be created in the Resource Group '${resourceGroup}' if the command executes successfully.`);
            } else {
                vscode.window.showErrorMessage("Failed to send the command to terminal, please try it again.");
            }
        }
    }