Rego
The policy language of Open Policy Agent, in which rules are sets of conditions over JSON input.
In more detail
Lines inside one rule body must all hold, so they are ANDed; rules sharing a name are ORed. A lookup that finds nothing makes the body undefined rather than false, which is why a default value and an explicit true matter.
Examples
default allow := falsedeny contains msg if { ... }In Terraform: A Rego rule describes the conditions under which something is denied or allowed. OPA evaluates the rules against input data, such as a Terraform plan in JSON, and returns the decisions.Related terms
- Open Policy Agent — A general-purpose policy engine that evaluates Rego policies against JSON input and returns a JSON decision.
- undefined result — In Rego, the outcome when a rule has no value because no body succeeded, which is different from false.
- logical operator — An operator such as AND, OR or NOT that combines or reverses true-or-false conditions.
- policy as code — Writing organisational rules, such as required tags or allowed regions, as code that automatically checks every proposed change.
Taught in
- Policy-as-Code Architecture: OPA & Rego Syntax — Cloud Security & DevSecOps Engineering
- Enforcing OPA Guardrails on Terraform Plan Payloads — Cloud Security & DevSecOps Engineering
- Policy As Code With OPA — Infrastructure as Code with Terraform
- Collaboration And Governance: Teams, Policies, Registry And Health — HashiCorp Terraform Associate (004) Exam Prep