Automation · Compliance Automation
Policy as Code
Cheat sheet · https://pcornel.dk/topic.php?topic=6015
Answer
Policy as code writes compliance and security rules as code, with tools like Open Policy Agent (Rego), Sentinel or Kyverno, so policies are versioned, tested and enforced automatically in pipelines.
Remember
- OPA/Rego, Sentinel, Kyverno.
- Test policies like code.
- Enforce in pipelines.
First checks
opa eval / conftest test— OPA policies- Kyverno/Gatekeeper policies (Kubernetes) — admission
- Sentinel/OPA on Terraform plans — IaC
Verify in this order
change → policy evaluation → allow/deny
Where it usually breaks
Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6015