World map

 

BM: Baca dalam Bahasa Melayu

World T1: Blueprints

HCL blocks

You will learn: how to read a block, and how one block uses another.

Checked with OpenTofu 1.13 on 1 Nov 2026

The problem

Here is a tiny blueprint. What does it ask OpenTofu to make?

resource "random_pet" "stall" {
  length = 2
}

Pick one answer.

Watch

Tap the two lines where a new block starts.

Tap the lines that match.

0 of 2 found

A blueprint is made of block: One part of a blueprint. It starts with a type and labels, like resource "local_file" "sign", then its settings in { }.. This language is called HCL.

Try it

Build the first line of a block. It makes a file, and you call it menu.

Tap the pieces in the right order.

…

Predict

The sign uses ${random_pet.stall.id}. That is a reference: Using a value from another block by its address: type, name, then the value, like random_pet.stall.id.: type, name, then the value. What is stall here?

Pick one answer.

Try it

Open main.tf. Change Welcome to into Selamat datang ke. Then type tofu apply and yes.

Blueprint (your .tf files)init done

  • local_file.signnot built yet
  • random_pet.stallnot built yet

Built (the state file)

Nothing built yet.

Blueprint: 2 resources. Built: 0.

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

Check

Sort the parts of a block.

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

        You did it!

        You can now read a block and follow a reference.

        Go deeper (optional)

        Lines starting with # are comments. OpenTofu reads every .tf file in the folder as one blueprint. File names are only for people. In strings, \n is a new line and ${ } puts a value inside the text.

        The settings inside a block are called argument: One setting inside a block: a name, an equals sign and a value, like length = 2.. Each provider’s docs list the arguments its resources take.