TfVariable class final

One variable "<name>" { ... } declaration.

Stack.variable builds these and returns the handle an argument takes; synth emits the collected declarations under the top-level variable key, and refuses to emit a config that references an undeclared one.

final dbPassword = variable<String>('db_password', sensitive: true);

Fields left null are omitted so Terraform's own default applies. A variable with no defaultValue is required when the engine runs (terradart apply -- -var '<name>=...', or TF_VAR_<name>), which is the point for secrets: the value never enters synth output or any Dart-side artifact.

Annotations
  • @immutable

Constructors

TfVariable({TfType? type, String? description, Object? defaultValue, bool? sensitive, bool? nullable})
const

Properties

defaultValue → Object?
Default value, making the variable optional. Omitted when null — so a variable with no default is required, which is what a secret-bearing variable wants.
final
description → String?
Human-readable description, surfaced by terraform plan prompts.
final
hashCode → int
The hash code for this object.
no setterinherited
nullable → bool?
Whether null is an accepted value. Terraform defaults to true.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sensitive → bool?
Marks the value as sensitive so Terraform redacts it from plan and apply output. Set this on a variable that feeds a sensitive field, the fix a SensitiveLiteral synth issue suggests.
final
type → TfType?
Terraform type constraint. Left null, Terraform infers any.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
toTfJson() → Map<String, Object?>
The variable "<name>" block body. The name itself is the map key synth files this under, not part of the body.

Operators

operator ==(Object other) → bool
The equality operator.
inherited