Infrastructure as code (IaC) allows defining and managing infrastructure through code, but policy as code (PaC) extends this concept by defining compliance policies also through code to ensure security and regulatory standards. This guide explains using PaC with Terraform, focusing on two frameworks: HashiCorp Sentinel and Open Policy Agent (OPA). Sentinel integrates closely with Terraform configurations, supporting various enforcement modes. OPA, an open-source policy engine, applies rules through its own Rego language and integrates well with tools like GitHub Actions and Spacelift. Both tools provide scalable methods for automating policy compliance in cloud infrastructures.

23m read timeFrom spacelift.io
Post cover image
Table of contents
Why use Sentinel for policy as code?How to create and implement Sentinel policies for Terraform?

Sort: