Skip to main content
Display the output values from a deployed stack.

Usage

npx tfts output [stack] [options]

Description

The output command shows the values of TerraformOutput resources defined in your stack after deployment.

Options

OptionTypeDescriptionDefault
--appstringCommand to run the tfts appFrom cdktf.json
--outputstringOutput directorycdktf.out
--skipSynthbooleanSkip synthesis stepfalse
--jsonbooleanOutput in JSON formatfalse

Examples

Basic Usage

npx tfts output

Specific Stack

npx tfts output production

JSON Output

Get outputs in JSON format for scripting:
npx tfts output --json

Skip Synthesis

npx tfts output --skipSynth

Output Format

Default Format

instance_ip = "10.128.0.2"
bucket_name = "my-bucket-abc123"

JSON Format

{
  "instance_ip": {
    "value": "10.128.0.2",
    "type": "string"
  },
  "bucket_name": {
    "value": "my-bucket-abc123",
    "type": "string"
  }
}

Using Outputs in Scripts

# Get a specific output value
INSTANCE_IP=$(npx tfts output --json | jq -r '.instance_ip.value')
echo "Instance IP: $INSTANCE_IP"

Defining Outputs

Outputs are defined in your stack:
new TerraformOutput(this, "instance-ip", {
  value: instance.networkInterface.get(0).networkIp,
  description: "The internal IP of the instance",
});

new TerraformOutput(this, "secret", {
  value: secret.value,
  sensitive: true, // Hidden in logs
});