World map

 

BM: Baca dalam Bahasa Melayu

World T4: Modules & Pipelines

Provider pins and the lock file

You will learn: how the lock file makes every laptop and pipeline use the same provider versions.

Checked with OpenTofu 1.13 on 1 Nov 2026

The problem

It worked yesterday. Today, on a new laptop, tofu init picked a newer provider, and the plan looks different. What would have kept them the same?

Pick one answer.

Try it

This folder already ran tofu init. Read what it wrote down: cat .terraform.lock.hcl.

Blueprint (your .tf files)init done

  • local_file.menunot 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.

Watch

Tap the line with the exact version that init chose.

0 of 1 found

The lock file: .terraform.lock.hcl: the receipt tofu init writes. It records which provider versions it picked. Commit it to Git. records the exact provider version, plus checksums. Then every laptop installs the very same files.

Predict

The lock file is in Git. Next month, random 3.10 comes out. A teammate runs tofu init. Which version does she get?

Pick one answer.

Try it

Ben added a bell that needs a new provider, null. Run tofu plan, read the error, then fix it.

Blueprint (your .tf files)init done

  • local_file.menunot built yet
  • null_resource.bellnot built yet
  • random_pet.stallnot built yet

Built (the state file)

Nothing built yet.

Blueprint: 3 resources. Built: 0.

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

Check

Your .gitignore is ready. Sort each file.

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

      You did it!

      You can now read the lock file and keep provider versions the same everywhere.

      Go deeper (optional)

      To upgrade, change the pin if needed and run tofu init -upgrade. Then review the lock file change in a pull request. OpenTofu 1.13 writes checksums for every platform on init. tofu providers lock can still add them by hand. Terraform’s lock file has the same name, but its entries point at registry.terraform.io.

      Real mission

      1. tofu init
      2. cat .terraform.lock.hcl
      3. tofu init
      4. git add .terraform.lock.hcl *.tf && git commit -m "Pin providers"

      0 of 4 steps done Β· Your ticks are saved.