The word “module” in Terraform refers to both a theoretical concept and to a physical structure related to that concept.
The concept is a collection of resources and other declarations that share a common namespace and can freely refer to one another, as long as they do so in a way which creates a consistent dependency graph and valid expressions. Modules are roughly analogous to a function in a general-purpose programming language, and so they have parameters (input variables), return values (output values), and local symbols (local values).
The physical representation of a module is a directory of
.tf files. Every Terraform configuration has at least one module, which we call the root module. The root module’s input variables come from your command line arguments when you run
terraform plan or
terraform apply, and its output values get printed to the terminal and saved in the state so you can retrieve them separately using
A module can call another module, in which case the caller will set the callee’s input variables using expressions derived from its own resources and other objects, and it can use the callee’s output values as part of expressions elsewhere in its own configuration files.
I’m not sure what else to say to such a general question, but if you have other questions based on what I’ve said above then please add another comment and I’ll try to answer them.