Study HashiCorp Terraform 004 Variables and Outputs: key concepts, common traps, and exam decision cues.
Terraform configuration becomes easier to reason about when you keep the value flow clean: variables come in, resources and expressions use them, and outputs send useful values back out.
| Terraform term | Main role |
|---|---|
| variable | input into configuration or a module |
| output | value exported from configuration or a module |
| complex type | structured value such as a list, map, or object |
| Type idea | Why it matters |
|---|---|
| list or tuple | ordered collections |
| map | key-value lookup |
| object | structured named attributes |
Terraform Associate questions often use these types to test whether you understand value structure rather than memorized syntax alone.
| Trap | Better rule |
|---|---|
| confusing variables with outputs | variables go in; outputs come out |
| treating every input like a simple string | Terraform can accept richer structured data |
| assuming outputs replace state | outputs expose values; state still tracks managed infrastructure |
Think of variables as inputs and outputs as exported results. Then ask what data shape fits the scenario: lists for ordered collections, maps for keyed lookups, objects for structured records. Terraform Associate questions usually reward choosing the simplest type that matches the input contract rather than the most flexible-sounding one.