You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Modules are the primary way to organise, reuse, and share Terraform configuration. A module is simply a directory containing .tf files. This lesson covers creating modules, using module sources, the Terraform Registry, and module composition patterns.
Every Terraform configuration is a module:
terraform applymodule blockproject/
├── main.tf ← root module
├── variables.tf
├── outputs.tf
└── modules/
└── network/ ← child module
├── main.tf
├── variables.tf
└── outputs.tf
| Benefit | Description |
|---|---|
| Reusability | Write once, use across multiple projects |
| Organisation | Group related resources into logical units |
| Encapsulation | Hide implementation details behind a clean interface |
| Consistency | Enforce standards across your organisation |
| Testability | Test modules independently |
A module has the same file structure as any Terraform configuration:
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.