Terraform does not protect you from bad input.
If a variable accepts free-form strings, Terraform will treat every variation as valid.
That means prod, prd, and production can all create different resource paths, names, or policies.
The mechanism is simple.
Terraform builds infrastructure from whatever values you give it.
The outcome is silent drift that starts at the input boundary.
This lesson shows how to stop that early.
The contains function checks if a value exists inside an approved list.
That produces a boolean.
The validation block takes that boolean and enforces it.
If the value is not in the list, Terraform fails during the plan phase.
This is not about syntax.
This is about controlling what is allowed into your system before the graph is built.
One check at the boundary removes entire classes of configuration errors.
Lesson 89 breaks down how to turn simple membership logic into enforced infrastructure contracts.

