Variable scope within modules
Unlock the complete study guide + 1,040 practice questions across 16 full exams.
Bundled into the existing HashiCorp Certified: Terraform Associate premium course — no separate purchase.
14-day money-back guarantee — no questions asked.
Included in this chapter:
- The module boundary: two channels
- Passing inputs down into a child
- Reading results back up with outputs
- Providers: the exception to isolation
- Exam-pattern recognition
The three channels across a module boundary
| Aspect | Input variables | Output values | Provider configurations |
|---|---|---|---|
| Direction of flow | Caller into child | Child back to caller | Caller into child |
| How it is referenced | var.NAME inside the child | module.LABEL.OUTPUT in the caller | provider address, e.g. aws or aws.usw2 |
| Crosses automatically? | No; passed as a module argument | No; must be declared as an output | Default: yes (inherited); aliased: no |
| Declared in the child by | variable block | output block | required_providers plus configuration_aliases |
Cheat sheet
Unlock with Premium — includes all practice exams and the complete study guide.