From f4cc63b188ad912fb3523438d1bf453c9d958b11 Mon Sep 17 00:00:00 2001 From: Anubhav Mishra Date: Sat, 15 Aug 2020 11:37:31 -0700 Subject: [PATCH] use remote backend class for typescript template (#313) --- .../templates/typescript/.hooks.sscaff.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/cdktf-cli/templates/typescript/.hooks.sscaff.js b/packages/cdktf-cli/templates/typescript/.hooks.sscaff.js index c449d6a7c8..db21311f00 100644 --- a/packages/cdktf-cli/templates/typescript/.hooks.sscaff.js +++ b/packages/cdktf-cli/templates/typescript/.hooks.sscaff.js @@ -36,14 +36,13 @@ function installDeps(deps, isDev) { function terraformCloudConfig(baseName, organizationName, workspaceName) { template = readFileSync('./main.ts', 'utf-8'); - const result = template.replace(`new MyStack(app, '${baseName}');`, `const stack = new MyStack(app, '${baseName}'); -stack.addOverride('terraform.backend', { - remote: { - hostname: 'app.terraform.io', - organization: '${organizationName}', - workspaces: { - name: '${workspaceName}' - } + result = template.replace(`import { App, TerraformStack } from 'cdktf';`, `import { App, TerraformStack, RemoteBackend } from 'cdktf';`); + result = result.replace(`new MyStack(app, '${baseName}');`, `const stack = new MyStack(app, '${baseName}'); +new RemoteBackend(stack, { + hostname: 'app.terraform.io', + organization: '${organizationName}', + workspaces: { + name: '${workspaceName}' } });`);