TOPIC IAC
Terraform Modules reusable, versioned infrastructure components
IN 10 SECONDS
A module is any directory with `.tf` files that exposes `input` variables and `output` values. You call a module with `module "vpc" { source = "./modules/vpc", version = "1.2.0" }`. Root modules are your main config; child modules encapsulate reusable patterns like networking, compute, or databases.
GOTCHA Modules can't contain `provider` blocks (unless using Terraform 0.13+ with `required_providers`). Providers are inherited from the root config. Version your modules with Git tags or a registry to prevent accidental breaking changes.
HOW A MODULE WORKS
01 Terraform resolves the module source — a local path, Git URL, or Terraform Registry reference.
02 Terraform evaluates the module block's input variables and passes them to the module's scope.
03 Terraform merges the module's resources into the root graph — they're planned and applied alongside root resources.
04 Root config references module outputs via `module.vpc.vpc_id` for use elsewhere in the stack.
POKE IT YOURSELF
terraform init — downloads module sources and providers
terraform providers — inspect all provider versions in the module tree
Drill this topic →
~70 sec read