From f8e194858df8709e5bbe18df8130322e2220d03d Mon Sep 17 00:00:00 2001 From: Jye Cusch Date: Wed, 21 May 2025 18:46:33 +1000 Subject: [PATCH] fix(lib): respect hclOutput app config --- packages/cdktf/lib/app.ts | 2 +- packages/cdktf/lib/synthesize/synthesizer.ts | 3 +-- packages/cdktf/lib/terraform-stack.ts | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/cdktf/lib/app.ts b/packages/cdktf/lib/app.ts index 077c29ae18..2b3b097785 100644 --- a/packages/cdktf/lib/app.ts +++ b/packages/cdktf/lib/app.ts @@ -97,7 +97,7 @@ export class App extends Construct { const envHclOutput = process.env.SYNTH_HCL_OUTPUT; let hclOutput = config.hclOutput || false; if (envHclOutput !== undefined) { - hclOutput = envHclOutput === "true"; + hclOutput = envHclOutput === "true" || envHclOutput === "1"; } this.hclOutput = hclOutput; diff --git a/packages/cdktf/lib/synthesize/synthesizer.ts b/packages/cdktf/lib/synthesize/synthesizer.ts index 364decf973..c62e5adabd 100644 --- a/packages/cdktf/lib/synthesize/synthesizer.ts +++ b/packages/cdktf/lib/synthesize/synthesizer.ts @@ -24,7 +24,6 @@ export class StackSynthesizer implements IStackSynthesizer { constructor( protected stack: TerraformStack, private continueOnErrorAnnotations = false, - private hclOutput = false, ) {} synthesize(session: ISynthesisSession) { @@ -90,7 +89,7 @@ export class StackSynthesizer implements IStackSynthesizer { ); } - if (this.hclOutput) { + if (manifest.hclOutput) { const hcl = this.stack.toHclTerraform(); fs.writeFileSync( path.join(session.outdir, stackManifest.synthesizedStackPath), diff --git a/packages/cdktf/lib/terraform-stack.ts b/packages/cdktf/lib/terraform-stack.ts index 59bc3eef57..b0aa07797b 100644 --- a/packages/cdktf/lib/terraform-stack.ts +++ b/packages/cdktf/lib/terraform-stack.ts @@ -89,8 +89,6 @@ export class TerraformStack extends Construct { this.synthesizer = new StackSynthesizer( this, process.env.CDKTF_CONTINUE_SYNTH_ON_ERROR_ANNOTATIONS !== undefined, - process.env.SYNTH_HCL_OUTPUT === "true" || - process.env.SYNTH_HCL_OUTPUT === "1", ); Object.defineProperty(this, STACK_SYMBOL, { value: true }); this.node.addValidation(new ValidateProviderPresence(this));