Skip to main content
tfts provides first-class support for Terraform variables, outputs, and locals, allowing you to create flexible and reusable infrastructure definitions.

TerraformVariable

TerraformVariable allows you to define inputs for your stack. These can be provided via CLI arguments, environment variables, or terraform.tfvars files.

Configuration

A variable can have several properties:
  • type: The data type (string, number, bool, list, map, etc.).
  • default: A default value if none is provided.
  • description: Documentation for the variable.
  • sensitive: If true, the value is masked in CLI output.
  • nullable: Whether the variable can be null.
  • validation: Custom validation rules.

Usage

To use a variable’s value, you access its typed properties: value, stringValue, numberValue, booleanValue, or listValue.

TerraformOutput

TerraformOutput is used to export information from your stack. This is useful for sharing data between stacks or displaying important information (like an IP address) after deployment.

TerraformLocal

TerraformLocal (or “Locals”) allows you to assign a name to an expression. This is useful for avoiding repetition and simplifying complex logic.
Like variables, locals provide helper properties to cast the expression to specific types: asString, asNumber, asBoolean, and asList.

Complete Example

Here is how these concepts look when combined: