World map

 

BM: Baca dalam Bahasa Melayu

World T4: Modules & Pipelines

Modules: a stall you can reuse

You will learn: how to write one stall design and build it many times, with a module.

Checked with OpenTofu 1.13 on 1 Nov 2026

The problem

Kedai Kancil has three kiosks. Each one was copied and pasted into main.tf. Now every sign needs new wording. How many places do you edit?

Pick one answer.

Watch

This is modules/kiosk/main.tf. Tap its input and its output.

0 of 2 found

A module: A stall design you can reuse: a folder of .tf files. Variables go in, outputs come out. is a stall design you can reuse: a folder of .tf files. Variables go in, outputs come out.

Predict

You copy a module block in main.tf and name it roti. Then you run tofu plan. What happens?

Pick one answer.

Try it

Add a third kiosk. In main.tf, copy a module block. Name it roti, with name = "roti-canai". Then plan, init and apply.

Blueprint (your .tf files)init done

  • module.teh.local_file.sign
  • module.nasi.local_file.sign

Built (the state file)state #1

  • module.nasi.local_file.sign
  • module.teh.local_file.sign
teh_file
teh-tarik.txt
Blueprint: 2 resources. Built: 2.

Change a file, then run tofu plan to see what it means.

Check

This is tofu state list now. Find the new kiosk in the register.

Tap the address that belongs to module roti.

0 of 1 found

Check

Where does each line live: in the module, or in the blueprint that calls it?

Drag a card into a box. Or tap the card, then tap the box.

      You did it!

      You can now wrap a design in a module and build it many times.

      Go deeper (optional)

      Modules can call other modules. Keep them small and boring: one clear job each. A module with one resource and ten inputs is usually just extra typing. tofu init sets up modules too. tofu get fetches modules only.

      Real mission

      1. tofu init && tofu apply
      2. tofu state list

      0 of 4 steps done ยท Your ticks are saved.