Policy as Code (OPA, Sentinel) for Automated Compliance
The practice of expressing compliance and security policies as machine-readable, version-controlled code that can be automatically evaluated and enforced across infrastructure and deployments.
Policy as Code (PaC) is the practice of defining, managing, and enforcing organizational and regulatory policies as machine-readable code, stored in version control, and evaluated automatically at decision points throughout the software delivery lifecycle. The Open Policy Agent (OPA) and HashiCorp Sentinel are the dominant policy engines: OPA uses the Rego language to express policies evaluated against JSON data structures, with integrations for Kubernetes admission control (OPA Gatekeeper), API authorization (Envoy), infrastructure-as-code validation (Terraform), and CI/CD gate checking. Sentinel is embedded in the HashiCorp ecosystem for Terraform Cloud/Enterprise policy enforcement. For compliance teams, PaC transforms policies from documents that must be manually checked into automated controls that are continuously enforced.
Engineering a PaC compliance program requires translating regulatory requirements into machine-evaluable rules. PCI DSS requirement 8.2 (unique user IDs) becomes an OPA policy that evaluates IAM configurations and rejects any resource that allows shared credentials. HIPAA minimum necessary principle becomes a Sentinel policy that prevents Terraform plans from creating S3 buckets or databases with overly permissive access policies. These policies are committed to a policy repository alongside their test cases (OPA has a built-in testing framework; Sentinel policies have test mocks) and integrated into CI/CD pipelines as mandatory gates. Policy evaluations produce machine-readable results that can feed compliance dashboards showing the pass/fail rate of policy checks across all deployments.
A critical governance aspect of Policy as Code is policy lifecycle management. Policies must be versioned, and policy changes must go through the same review process as application code — including review by a compliance officer for material changes to regulatory interpretations. When a new regulation is published or an existing one is updated, the policy repository becomes the backlog for compliance engineering work, with specific policy changes tracked as tickets. Policy exceptions — where a specific resource is granted an exemption from a policy — must be documented with a risk acceptance, an expiration date, and the approver's identity, implemented as OPA/Sentinel exception records rather than simply disabling the policy check. The policy exception register becomes a compliance artifact reviewed during audits.
We build Policy as Code programs using OPA and Sentinel, translating regulatory requirements from PCI DSS, HIPAA, SOX, and NIST frameworks into tested, version-controlled Rego and Sentinel policies with CI/CD integration. Our implementations include policy lifecycle management workflows, exception tracking with risk acceptance documentation, and compliance dashboards that aggregate policy evaluation results across deployments.
Compliance-Native Architecture Guide
Design principles and a structured checklist for building software that is compliant by default — not compliant by retrofit. Covers data architecture, access controls, audit trails, and vendor due diligence.