Skip to content

Commit

Permalink
use remote backend class for typescript template (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
anubhavmishra authored Aug 15, 2020
1 parent ebbbdfc commit f4cc63b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/cdktf-cli/templates/typescript/.hooks.sscaff.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
}
});`);

Expand Down

0 comments on commit f4cc63b

Please sign in to comment.