BM: Baca dalam Bahasa Melayu
World T3: State & Teams
Sensitive values and secrets in state
You will learn: why sensitive hides a secret on screen only, and how to protect the register.
Checked with OpenTofu 1.13 on 1 Nov 2026
The problem
The shop safe gets a PIN from random_password. tofu output prints pin = <sensitive>. Is the PIN safe now?
Pick one answer.
Try it
Run tofu plan and read the error. Then add sensitive = true to the output in main.tf, and run tofu apply.
Blueprint (your .tf files)init done
local_sensitive_file.safenot built yetrandom_password.pinnot built yet
Built (the state file)
Nothing built yet.
Change a file, then run tofu plan to see what it means.
Hint
Plain words: an output that holds a secret must say so.Watch
This is part of terraform.tfstate. Tap every line where the PIN shows.
0 of 3 found
A sensitive value: A value hidden in plans and outputs. The state file still keeps it as plain text. is hidden in plans and outputs. The register still keeps it, as plain text.
Try it
The screen hides it, but ask OpenTofu directly: tofu output -raw pin.
Blueprint (your .tf files)init done
local_sensitive_file.saferandom_password.pin
Built (the state file)state #1
local_sensitive_file.saferandom_password.pin
- pin
- (hidden: sensitive)
Change a file, then run tofu plan to see what it means.
Predict
Your repo is about to be pushed. Sort each file.
Drag a card into a box. Or tap the card, then tap the box.
Check
Who should be able to read the register?
Pick one answer.
Check
Swipe: does this protect the register, or does it need work?
Swipe right for good, left for needs work. Or use the buttons.
A backend bucket with encryption and tight access rules
You did it!
You can now tell where secrets hide in OpenTofu, and how to protect the register.
Go deeper (optional)
OpenTofu 1.11 added ephemeral resources and write-only attributes. They keep a secret out of the register and the plan altogether. Terraform has them too (1.10 and 1.11). Lesson T4ยท7 shows how a pipeline gets secrets without files.
Real mission
tofu init && tofu applytofu outputgrep result terraform.tfstateprintf "*.tfstate\n*.tfstate.*\n.terraform/\n" >> .gitignore
0 of 4 steps done ยท Your ticks are saved.
Bahasa Melayu
Peti besi kedai dapat PIN dari random_password. tofu output papar pin = <sensitive>. Adakah PIN itu selamat sekarang?
Jalankan tofu plan dan baca ralatnya. Kemudian tambah sensitive = true pada output dalam main.tf, dan jalankan tofu apply.
Nilai sensitif disorok dalam plan dan output. Daftar masih simpannya, sebagai teks biasa.
Skrin sorokkannya, tapi tanya OpenTofu terus: tofu output -raw pin.
Repo anda hampir di-push. Susun setiap fail.
Siapa patut boleh baca daftar?
Leret: adakah ini lindungi daftar, atau perlu dibaiki?
Kini anda tahu di mana rahsia bersembunyi dalam OpenTofu, dan cara lindungi daftar.
You finished this before. Practice is always welcome!
Official docs: OpenTofu: sensitive data in state ยท OpenTofu: output values (sensitive) ยท OpenTofu: state encryption ยท OpenTofu: ephemerality ยท Terraform: manage sensitive data
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?