Terraform modules: inputs, outputs and versions
A module interface
A child module receives input variables and exposes output values. It doesn’t automatically inherit variables from the calling module. Pass each required value and check the declared type.
module "dispatch" {
source = "./modules/service"
name = "cedar-dispatch"
region = "north"
}
output "dispatch_id" {
value = module.dispatch.id
}
This original example assumes that the local module declares name and region inputs and an id output. A different module needs its own interface. File paths and provider schemas in the browser model are teaching contracts.
Version and identity boundaries
A local module path identifies code in the working tree. Registry modules support a version constraint; a Git source uses its supported source-reference syntax. The provider lockfile records provider selections, not a lock of all module source code.
Renaming a module call also changes addresses below it. Review the moved-block exercises before a refactor so that a new address doesn’t accidentally become a destroy-and-create plan. The HashiCorp module reference explains the full language model.
Continue with module outputs and module version constraints.