Modules Intro

View saved

What a module is

A module is a folder of .tf files with inputs (variables) and outputs. The directory you run Terraform in is the root module.

Call a local module

Example layout: modules/hello/ with its own resources, then from root:

module "greeting" {
  source   = "./modules/hello"
  greeting = "Hello from a module"
}

Why modules help

Share a standard pattern (a small app stack, a locked-down bucket) without copy-paste. Start extracting only after a pattern repeats.

Registry awareness

Public modules exist on the Terraform Registry. Read them carefully—prefer official or well-maintained sources for learning.

Comments

One comment per signed-in account. Comments are saved with this page’s URL.