- The root (parent) module is the top-level configuration that invokes other modules.
- A child module is a reusable unit of configuration — for example, a networking module or a compute module.
- Typical module files:
main.tf— resources and module invocationsvariables.tf— input variable declarationsoutputs.tf— exported values for callers
- Each module has its own variable namespace (scope).
- Variables declared in one module are not visible to other modules unless explicitly passed or exported as outputs.
- This isolation makes modules more reusable and less prone to accidental coupling.
environment or region from the root, and the root does not automatically see cidr_block or az_count from the child. This behavior is intentional: modules act like black-box functions that only observe inputs you provide.

Modules have isolated scopes. You must explicitly pass values between modules; variables are not shared implicitly.
module block of the calling (root) module. Each argument corresponds to a declared input variable in the child module.
Example — passing a root variable into a child module:
- Root variables:
var.<NAME>(e.g.,var.environment) - Resource attributes:
aws_vpc.example.id - Another module’s outputs:
module.network.subnet_ids[0] - Hard-coded literals:
"us-west-2",42,true
| Value type | Example |
|---|---|
| Root variable | var.environment |
| Resource attribute | aws_vpc.example.id |
| Module output | module.network.subnet_ids[0] |
| Literal | "us-west-2" |
- Child-module variables can include defaults (for example,
az_count = 2). If the caller doesn’t pass a value, the child uses that default. - Well-designed modules provide sensible defaults while permitting callers to override behavior via input variables.
output blocks. The root (or another calling module) can then read those outputs via module.<NAME>.<OUTPUT>.
Example — child module outputs:

- Variables are scoped to the module where they are declared.
- To provide input to a child module, pass values in the
moduleblock of the calling module. - To expose values from a child module to its caller, create
outputblocks in the child and reference them viamodule.<NAME>.<OUTPUT>. - Values passed between modules can be root variables, resource attributes, other module outputs, or literals — ensure the receiving module declares the corresponding input variable.
- Terraform Modules Overview
- Terraform Input Variables
- Terraform Output Values
- Terraform Registry
- HashiCorp Certified: Terraform Associate training (KodeKloud)