Skip to main content
Synthesize your TypeScript infrastructure code into Terraform JSON configuration.

Usage

npx tfts synth [options]

Aliases

  • synthesize

Description

The synth command executes your tfts application and generates Terraform JSON configuration files. The output is written to the specified output directory (default: cdktf.out).

Options

OptionTypeDescriptionDefault
--appstringCommand to run the tfts appFrom cdktf.json
--outputstringOutput directory for synthesized filescdktf.out

Examples

Basic Usage

npx tfts synth
Runs the app command from cdktf.json and outputs to cdktf.out/.

Custom App Command

npx tfts synth --app "npx ts-node main.ts"

Custom Output Directory

npx tfts synth --output terraform-out

Output Structure

After synthesis, the output directory contains:
cdktf.out/
├── manifest.json           # Stack metadata
└── stacks/
    └── my-stack/
        └── cdk.tf.json     # Terraform configuration

Using with Terraform

After synthesis, navigate to the stack directory and run Terraform:
cd cdktf.out/stacks/my-stack
terraform init
terraform plan
terraform apply

Environment Variables

VariableDescription
CDKTF_OUTDIROverride output directory
CDKTF_TARGET_STACK_IDSynthesize only a specific stack