How does policy-as-code with OPA/Conftest relate to Checkov?

IntermediateConceptCheckov
Answer

Short answer

Checkov comes with ready-made security policies for common misconfigurations. OPA (Open Policy Agent) with Conftest is a general policy engine where you write your own rules in Rego — ideal for organisation-specific rules (approved regions, mandatory tags, naming) on Terraform plans, Kubernetes YAML or any JSON/YAML. Many teams use Checkov for broad security coverage and OPA for custom governance.

Conftest example (Rego) on a Terraform plan

package main

deny contains msg if {
  r := input.resource_changes[_]
  r.type == "aws_instance"
  not r.change.after.tags.owner
  msg := sprintf("%s must have an 'owner' tag", [r.address])
}
terraform show -json tfplan > tfplan.json
conftest test tfplan.json

Where each fits

Need Tool
Broad security baseline, compliance mapping Checkov / Trivy
Custom org rules, any JSON/YAML OPA / Conftest
Admission control in Kubernetes OPA Gatekeeper or Kyverno

What to say in the interview

"Checkov provides a large library of built-in security checks; OPA with Conftest is a general engine for custom Rego rules on plans and manifests. We use Checkov for the security baseline and OPA for company-specific governance."

All Security Tools questions Roadmap: Checkov — IaC security

More on Checkov