externalVariable<T> method

TfArgVariable<T> externalVariable<T>(
  1. String name
)

The handle for a variable declared in a hand-written file beside the generated main.tf.json, accepted by the reference check without emitting a block for it.

Terraform merges every .tf / .tf.json file in the module directory, so a hand-written variables.tf is a legitimate way to declare inputs — and the only way to express what TfVariable does not model, such as validation { ... } blocks. Emitting a second declaration for the same name would be a duplicate-variable error, so this registers the name for the reference check alone.

Prefer variable when the declaration can live in Dart: it keeps the whole module in one place, and the block travels with the stack.

Throws ArgumentError if name is not a Terraform identifier or is already registered by either variable or this method.

Implementation

TfArgVariable<T> externalVariable<T>(String name) {
  _declareVariableName(name);
  _externalVariables.add(name);
  return TfArgVariable<T>(name);
}