Using modules in configuration
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:
- Calling a child module
- Running many instances with count and for_each
- Wiring a module: providers and depends_on
- Exam-pattern recognition
Plain call vs count vs for_each on a module
| Aspect | Plain module block | count | for_each |
|---|---|---|---|
| Instances created | Exactly one | A whole number N | One per map or set element |
| Instance address | module.NAME | module.NAME[0], [1], … | module.NAME["key"] |
| Key available inside | None | count.index (0-based) | each.key and each.value |
| Accepted value type | n/a | Whole number | Map or set of strings, not a list |
| Best fit | A single instance | Nearly identical copies | Copies with stable identities |
Decision tree
Cheat sheet
Unlock with Premium — includes all practice exams and the complete study guide.