Open Policy Agent
A general-purpose policy engine that evaluates Rego policies against JSON input and returns a JSON decision.
In more detail
OPA decides and the caller enforces. It knows nothing about buckets or Terraform, only documents, and runs as a server on port 8181, as a library or as a one-off opa eval.
Example
In Terraform: In the course pipeline OPA evaluates the output of terraform show -json and can reject public storage, missing tags or unapproved regions. Tools such as Conftest run OPA policies in a pipeline step.Related terms
- Rego — The policy language of Open Policy Agent, in which rules are sets of conditions over JSON input.
- policy as code — Writing organisational rules, such as required tags or allowed regions, as code that automatically checks every proposed change.
- OPA decision API — OPA's HTTP interface: the caller POSTs its input as JSON to /v1/data/ plus a policy path and receives the decision as JSON.
- Conftest — A command-line tool that runs Rego policies against configuration files such as Terraform plan JSON, YAML and Dockerfiles.
- JSON plan representation — The machine-readable form of a saved plan, produced by terraform show -json, which lists every planned change and value.
Taught in
- Friday At Five To Five: DevOps And DevSecOps — Certified GitOps Associate (CGOA) Exam Prep
- Policy-as-Code Architecture: OPA & Rego Syntax — Cloud Security & DevSecOps Engineering
- Enforcing OPA Guardrails on Terraform Plan Payloads — Cloud Security & DevSecOps Engineering
- Forty Minutes Of Yes: Admission Control — Kubernetes and Cloud Native Security Associate (KCSA) Exam Prep
- Which Benchmark, And Who Checked It? Compliance And Frameworks — Kubernetes and Cloud Native Security Associate (KCSA) Exam Prep
- Running Terraform In CI — Infrastructure as Code with Terraform
- Native Testing With Tftest Files — Infrastructure as Code with Terraform
- Provider Mocking For Tests — Infrastructure as Code with Terraform
- Policy As Code With OPA — Infrastructure as Code with Terraform
- Releasing The Real Cloud Artifact — Infrastructure as Code with Terraform
- Collaboration And Governance: Teams, Policies, Registry And Health — HashiCorp Terraform Associate (004) Exam Prep