IAC / A CONCEPT NOTE
Terraform Modules
reusable, versioned infrastructure components
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
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.
02 / FOLLOW THE MECHANISM
How a module works
Terraform
resolves the module source — a local path, Git URL, or Terraform Registry reference.
Terraform
evaluates the module block's input variables and passes them to the module's scope.
Terraform
merges the module's resources into the root graph — they're planned and applied alongside root resources.
Root config
references module outputs via
module.vpc.vpc_idfor use elsewhere in the stack.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
downloads module sources and providers
terraform initinspect all provider versions in the module tree
terraform providers05 / CHECK YOURSELF
Could you explain Terraform Modules to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in Infrastructure as codeGitOpsgit as the single source of truth for deployments