Skip to content
Vol. 1 · Ed. 2026
CyberGlossary
Entry № 839

Policy as Code

What is Policy as Code?

Policy as CodeThe practice of defining security, compliance, and governance rules in machine-readable code so they can be versioned, tested, reviewed, and automatically enforced.


Policy as Code (PaC) treats organizational policies — what configurations are allowed, who can do what, which regions data can land in — as source code stored in a Git repository, tested in CI, reviewed via pull requests, and enforced by automated engines. Common implementations include OPA with Rego, Kyverno for Kubernetes, HashiCorp Sentinel for Terraform, AWS Config Rules and Azure Policy. PaC removes ambiguity from PDFs and wikis: a deny on privileged containers becomes a concrete failing test, and compliance reports can be generated from the same rules. The approach scales governance across many teams and clouds, integrates with DevSecOps pipelines, and produces auditable evidence of enforcement.

Examples

  1. 01

    An OPA Rego rule that denies any Kubernetes Pod missing readinessProbe in production.

  2. 02

    A Sentinel policy that blocks Terraform plans creating S3 buckets without encryption.

Frequently asked questions

What is Policy as Code?

The practice of defining security, compliance, and governance rules in machine-readable code so they can be versioned, tested, reviewed, and automatically enforced. It belongs to the Cloud Security category of cybersecurity.

What does Policy as Code mean?

The practice of defining security, compliance, and governance rules in machine-readable code so they can be versioned, tested, reviewed, and automatically enforced.

How does Policy as Code work?

Policy as Code (PaC) treats organizational policies — what configurations are allowed, who can do what, which regions data can land in — as source code stored in a Git repository, tested in CI, reviewed via pull requests, and enforced by automated engines. Common implementations include OPA with Rego, Kyverno for Kubernetes, HashiCorp Sentinel for Terraform, AWS Config Rules and Azure Policy. PaC removes ambiguity from PDFs and wikis: a deny on privileged containers becomes a concrete failing test, and compliance reports can be generated from the same rules. The approach scales governance across many teams and clouds, integrates with DevSecOps pipelines, and produces auditable evidence of enforcement.

How do you defend against Policy as Code?

Defences for Policy as Code typically combine technical controls and operational practices, as detailed in the full definition above.

What are other names for Policy as Code?

Common alternative names include: PaC.

Related terms