BM: Baca dalam Bahasa Melayu
World T4: Modules & Pipelines
Policy checks
You will learn: how a written rule checks every plan, and stops the risky ones before review.
Checked with OpenTofu 1.13 on 1 Nov 2026
The problem
A robot reads every plan before a human does. Swipe: let it through (good), or stop it (needs work)?
Swipe right for good, left for needs work. Or use the buttons.
The plan adds one kiosk
Watch
Tap the line that looks for things being destroyed.
0 of 1 found
A policy check: A written rule a robot checks on every plan, like: nothing may destroy the database. is a written rule a robot checks on every plan. This one is Rego, the rule language of Open Policy Agent.
Try it
Put the policy steps in order.
First at the top. Put these in order. Use the arrows, or drag.
- tofu show -json tfplan > plan.json
- conftest test plan.json
- A red check stops the merge until someone looks
- tofu plan -out tfplan
Predict
The plan replaces the stall (-/+). It does not plainly destroy it. Does the rule catch it?
Pick one answer.
Watch
A real run, Conftest 0.71. The stall was replaced, the fridge removed. Both are caught, so the check turns red.
Check
What should a robot rule check, and what needs a human?
Drag a card into a box. Or tap the card, then tap the box.
You did it!
You can now read a policy rule and put it in the pipeline.
Go deeper (optional)
Other tools: Checkov and Trivy scan .tf files for risky settings. HCP Terraform can run Sentinel or OPA policies. Inside OpenTofu, variable validation and check blocks are rules too. Tip: start new rules as warnings, then make them errors.
Real mission
tofu plan -out tfplantofu show -json tfplan > plan.jsondocker run --rm -v "$PWD:/project" -w /project openpolicyagent/conftest:v0.71.1 test plan.json
0 of 4 steps done · Your ticks are saved.
Bahasa Melayu
Robot baca setiap plan sebelum manusia. Leret: biar lalu (bagus), atau hentikan (perlu dibaiki)?
Semakan polisi ialah peraturan bertulis yang robot semak pada setiap plan. Yang ini Rego, bahasa peraturan Open Policy Agent.
Susun langkah polisi mengikut urutan.
Plan itu gantikan gerai (-/+). Ia tak musnahkannya secara terang. Adakah peraturan itu tangkap?
Larian sebenar, Conftest 0.71. Gerai diganti, peti sejuk dibuang. Kedua-duanya ditangkap, jadi semakan jadi merah.
Apa yang robot patut semak, dan apa perlukan manusia?
Kini anda boleh baca peraturan polisi dan letakkannya dalam pipeline.
You finished this before. Practice is always welcome!
Official docs: Conftest · Open Policy Agent docs · tofu show -json · OpenTofu: JSON output format
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?