By NHI Mgmt Group Editorial TeamBased on Orca Security: “What Is Open Policy Agent? Best Practices and Use Cases” (June 4, 2026)

TL;DR: OPA decouples policy from application code so the same authorization logic can govern Kubernetes, API gateways and Terraform pipelines with consistent Rego decisions, according to Orca Security. That helps reduce policy fragmentation, but it also makes logging, modular design and control mapping non-negotiable for identity governance.


At a glance

What this is: This is an analysis of Open Policy Agent as a policy-as-code control plane that centralises authorization logic across cloud systems and reduces enforcement drift.

Why it matters: IAM, IGA and cloud security teams need to understand how policy-as-code changes control ownership, audit evidence and change management across NHI and platform access paths.


Context

Policy fragmentation is the core problem here: when the same authorization rule is re-implemented in Kubernetes, API gateways and Terraform pipelines, enforcement drifts even if the intent stays the same. In identity governance terms, that creates different decision points for the same access rule, which weakens auditability and incident response.

OPA addresses that gap by separating policy from application code and evaluating structured inputs through Rego. The operational question for practitioners is not whether policy can be centralised, but how to preserve control fidelity when one policy engine governs multiple cloud identity enforcement points.


Key questions

Q: How should security teams implement policy as code across Kubernetes and Terraform?

A: Start with one policy language, one decision engine and separate enforcement points. Use Rego for the shared logic, then apply it through Kubernetes admission controls, gateway checks and pipeline gates. Keep policy files versioned, tested and tied to named controls so the same rule produces the same decision everywhere.

Q: Why does policy centralisation improve auditability but increase governance risk?

A: Centralisation creates a single place to log decisions, which strengthens evidence and consistency. The risk comes when the central policy no longer matches the current control baseline, because every system depending on it can inherit the same stale assumption. Governance improves only when the policy library is versioned, reviewed and mapped to specific standards.

Q: What signs show that policy as code is drifting out of sync with control requirements?

A: Look for policies that still evaluate successfully while the underlying benchmark, cloud architecture or access model has changed. Other warning signs include unclear control mappings, inconsistent rule exceptions across teams, and decision logs that cannot be tied back to a named requirement. Those are governance drift indicators, not just implementation noise.

Q: What should IAM and cloud teams do after a policy decision is denied in production?

A: Triage the denial against the control objective, the policy version and the affected deployment context before changing the rule. A denial can indicate a legitimate safeguard, an outdated benchmark mapping or a poorly modelled input. Treat it as a governance signal first, then decide whether the policy, the workload or the change request needs revision.


Technical breakdown

How Rego turns policy intent into structured decisions

OPA evaluates three things at runtime: the policy, the input, and any external data. Rego is declarative, so it describes what should be true under given conditions rather than encoding procedural logic inside each application. That matters because the same rule can be evaluated against Kubernetes manifests, Terraform plans, or API requests without changing the underlying policy semantics. When the decision is allow or deny, the caller enforces the result, not the policy file. This architecture is what makes OPA portable, but also what makes governance dependent on clean policy scoping and disciplined input modelling.

Practical implication: Map each Rego policy to a clearly bounded enforcement context so one decision model does not silently govern multiple identity surfaces.

Why policy-as-code creates auditability and drift risk at the same time

OPA improves auditability by producing decision logs that record inputs, results, timestamps and policy metadata. At the same time, centralisation creates a new drift risk if policy bundles, review cycles and benchmark mappings are not version-controlled with the same discipline as application code. A policy can keep returning valid decisions while still enforcing outdated assumptions, especially when benchmark versions or internal standards change. For IAM and cloud teams, the governance issue is not just whether a deny decision exists, but whether the policy still reflects current access requirements and control baselines.

Practical implication: Tie each policy package to a named control or benchmark version and review it whenever the underlying standard changes.

Where OPA changes cloud identity control points

OPA acts as a pre-deployment gate in CI/CD, an admission controller in Kubernetes, and an authorization layer for API decisions. That means identity controls can move earlier in the delivery lifecycle, before risky infrastructure or access changes are applied. For non-human identities, this matters because service account permissions, deployment logic and cluster admission rules often intersect in the same change set. If those paths are governed separately, the organisation can approve a build while still introducing an access problem at runtime. OPA narrows that gap by enforcing policy before deployment or admission, but only if the policy library reflects the actual identity model in use.

Practical implication: Use one policy model to review service account, workload and infrastructure changes before they reach production.


NHI Mgmt Group analysis

OPA solves enforcement fragmentation, but it does not solve governance fragmentation. One policy language across Kubernetes, API gateways and Terraform reduces duplicated rules, yet the organisation still has to decide which controls own which decisions. If the mapping is weak, a central policy engine simply makes inconsistent governance easier to deploy at scale. The practitioner takeaway is that policy centralisation only works when control ownership is explicit.

Decision logging is the difference between policy intent and policy evidence. OPA can record the input, result, timestamp and policy version for each decision, which turns enforcement into an auditable event stream. That is valuable for compliance, but only if the log is retained and interpreted as control evidence rather than telemetry noise. The field should treat decision logs as a governance record, not an afterthought.

Policy as code becomes an identity control plane when access rules span build, admission and runtime. That is especially relevant for NHI governance because service accounts, deployment identities and workload permissions often interact in the same delivery path. The discipline shifts from asking whether access is allowed to asking where the decision should occur and which lifecycle owns it. Practitioners should align policy-as-code with the identity lifecycle, not just with application delivery.

Modular policy design is the only sustainable way to scale Rego across multiple enforcement points. A single undifferentiated policy file is harder to test, harder to audit and easier to break when one environment changes. The article’s best-practice guidance points to the real operating model: separate packages for separate enforcement contexts, with shared helper rules only where the underlying control objective is the same. Teams should govern the library like production code.

OPA reinforces the broader move from application-local authorisation to centralised control logic. That shift validates policy-as-code for cloud operations, but it also raises the bar for review cadence, observability and benchmark mapping. Identity teams should see this as a control architecture decision, not a syntax decision. The right question is which access decisions belong in a shared policy plane and which still need tighter domain-specific ownership.

What this signals

Policy as code only becomes durable when it is treated as part of identity governance, not as a developer convenience layer. Centralising Rego decisions across cloud systems creates consistency, but it also concentrates accountability in one policy plane. Teams should expect more, not less, scrutiny over version control, control mapping and evidence retention.

Cloud identity programmes should start asking where the decision belongs, not just whether the decision is allowed. OPA shifts enforcement earlier in the lifecycle, which is useful when service accounts, workloads and infrastructure changes are intertwined. The real programme question is whether your control design can keep up with that shift.

Modular policy libraries are now a governance requirement, not just an engineering preference. When one policy file governs multiple enforcement points, the smallest change can create unexpected access outcomes. Practitioners should use policy structure to preserve clear ownership across Kubernetes admission, API authorization and CI/CD gates.


For practitioners

  • Map each policy to a named control Bind every Rego rule to a specific benchmark, compliance requirement or internal standard so the enforcement purpose is explicit and reviewable.
  • Split policies by enforcement context Separate Kubernetes admission, Terraform validation and API authorization into different packages so tests and failures stay isolated.
  • Enable decision logging from day one Forward policy inputs, results, timestamps and policy version metadata into your SIEM so enforcement evidence exists when auditors ask for it.
  • Pin policies to benchmark versions Track which CIS, PCI-DSS or internal control version each policy enforces, and update the Rego bundle when the standard changes.
  • Measure evaluation latency in production Use profiling and metrics to find policies that add delay in high-throughput admission or authorization paths before they become outage risks.

Key takeaways

  • OPA reduces policy fragmentation across cloud systems, but the governance burden moves to policy scoping, versioning and evidence handling.
  • Decision logging and benchmark mapping are central to making policy-as-code auditable and defensible in real operations.
  • Identity teams should treat central policy enforcement as a control architecture choice that needs explicit ownership across build, admission and runtime.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 addresses the attack and risk surface, while NIST CSF 2.0, CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-05 — Overprivileged NHIOPA is used here to constrain cloud and service identity permissions before they are applied.
NHI-04 — Insecure AuthenticationOPA governs structured authorization decisions that sit alongside identity trust boundaries.
Recommendation — Use policy-as-code to restrict overprivileged service and workload identities before deployment. Review identity decision points so authentication and authorization logic stay consistently enforced.
NIST CSF 2.0PR.AA-05 — Access Permissions, Entitlements and AuthorizationsOPA centralises permission and entitlement enforcement across cloud systems.
Recommendation — Map policy-as-code rules to PR.AA-05 and keep authorisation decisions aligned across environments.
CIS Controls v8CIS-5 — Account ManagementThe article covers policy controls for service and workload access in cloud pipelines.
Recommendation — Apply account management controls to keep service and workload access rules consistent across delivery stages.
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementPolicy changes and decision evidence depend on lifecycle governance for machine credentials and access.
Recommendation — Use IA-5 to govern credential-based access rules that OPA enforces across systems.

Key terms

  • Policy as Code: Policy as code stores authorization logic in version control and evaluates it through testable, reviewable rules. For agent governance, it makes runtime decisions reproducible and measurable, which is critical when actions can be triggered by untrusted content and executed at machine speed.
  • Rego: Rego is OPA’s declarative policy language for expressing what conditions permit or deny a request. It works well with structured data such as JSON and YAML, and its deterministic evaluation model makes it suitable for real-time authorization and compliance decisions.
  • Decision Logging: Decision logging is the recording of allow and deny outcomes together with the policy context that produced them. It gives security teams evidence for audits, investigations, and recertification, and it helps detect when authorization behaviour changes unexpectedly.
  • Admission Controller: An admission controller is a Kubernetes control that validates or changes workload requests before the cluster admits them. It acts as a deployment-time policy layer, which makes it useful for blocking unsafe images, rejecting risky configuration, and enforcing runtime standards that build-time scans may miss.

Deepen your knowledge

NHI governance, agentic AI identity, and machine identity lifecycle are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are building or maturing an IAM programme, it is worth exploring.
NHIMG Editorial Note
Published by the NHIMG editorial team on June 9, 2026.
Updated on October 10, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org