What is a Terraform Module?
Answer
A Terraform Module is a container for multiple resources that are used together. Every directory containing Terraform files is a module. The directory you run Terraform from is the root module. Reusable modules are called child modules. Call a module: module "vpc" { source = "./modules/vpc"; region = var.region; cidr_block = "10.0.0.0/16" }. Source can be a local path, Terraform Registry path ("terraform-aws-modules/vpc/aws"), Git URL, or S3 bucket. Modules encapsulate complexity — a VPC module might create the VPC, subnets, internet gateway, route tables, and NAT gateways internally, exposing only vpc_id and subnet_ids as outputs. The Terraform Registry has hundreds of official and community modules for common infrastructure patterns.
Previous
What are Terraform Outputs?
Next
What is the difference between terraform plan and terraform apply?