Terraform Module Sources and Interfaces

How Terraform modules package reusable configuration and expose a stable interface through inputs and outputs.

On this page

A Terraform module is a reusable package of configuration. The root module is the directory where Terraform runs; child modules are called from it. A module source can be a local directory, a registry address, or a supported remote source. Its public interface consists chiefly of input variables and outputs, not its internal resource addresses.

1module "network" {
2  source = "./modules/network"
3  cidr   = "10.0.0.0/16"
4}
5
6output "network_id" {
7  value = module.network.vpc_id
8}

Keep a module focused on one coherent responsibility and give variables descriptive types and documentation. A module is not a workspace: modules package code, while workspaces select distinct state instances. See Terraform’s module documentation.

Revised on Friday, September 11, 2026