Terraform module

A directory of Terraform files with inputs (variables) and outputs, which other configurations can call to reuse the same infrastructure design.

In more detail

Every configuration is a module; the one you run commands in is the root module, and the ones it calls are child modules. A module block names the source and passes values for the child's variables, and the caller reads results as module.<name>.<output>. A good module has a small interface and keeps provider details private.

Example

module "network" {
  source  = "./modules/network"
  name    = var.network_name
  subnets = var.subnet_names
}

Related terms

Taught in

References

Certification courses