Course contentsShow
← Cloud and Infrastructure
Lesson 837 of 2,98915. Terraform in PracticeFree lesson

Policy Enforcement with Sentinel

Implement policy-as-code using Sentinel to enforce governance and compliance across all Terraform runs.

Policy Enforcement with Sentinel

What you'll learn: How to use Sentinel to automatically enforce governance rules and compliance policies across all Terraform runs, preventing non-compliant infrastructure before it's provisioned.

What Is Sentinel?

Sentinel is a policy-as-code framework integrated with Terraform Cloud and Terraform Enterprise. Think of it as a security guard that checks every Terraform plan before it's applied—if the plan violates your organization's rules (like deploying resources in the wrong region, using unapproved instance types, or missing required tags), Sentinel blocks it automatically.

Instead of manually reviewing every Terraform change, you write policies once and Sentinel enforces them consistently across all workspaces and teams.

How Sentinel Works

Sentinel policies are written in a simple, declarative language and evaluate the contents of Terraform plans. When someone runs terraform plan in Terraform Cloud, Sentinel inspects the proposed changes before apply:

  1. Terraform generates a plan
  2. Sentinel evaluates all active policies against that plan
  3. Policies return pass, fail, or advisory (warning)
  4. Hard failures block the apply; advisories warn but allow override

Common Policy Use Cases

  • Cost control: Block expensive instance types or enforce budget tags
  • Security compliance: Require encryption for storage, enforce network rules
  • Resource standards: Mandate naming conventions, require specific tags
  • Regional restrictions: Limit deployments to approved regions only
  • Governance: Prevent public access to sensitive resources

Why It Matters at Scale

When managing infrastructure across multiple teams (as covered in Terraform Cloud collaboration), human reviews don't scale. Sentinel automates compliance checks, preventing configuration drift from organizational standards before resources are created.

Key Takeaway: Sentinel enables policy-as-code enforcement by automatically validating Terraform plans against governance rules, catching compliance violations before infrastructure changes are applied.