terraform plan and terraform apply stages, ensuring your infrastructure remains compliant before changes are applied.

Prerequisites: Teams & Governance Tier
Sentinel policies require the Teams & Governance tier in Terraform Cloud. In Settings → Plan & Billing, activate your free trial or subscription for this tier to unlock Policy as Code, cost estimation, and run tasks.You must have an active Teams & Governance plan in Terraform Cloud before you can enforce Sentinel policies.



Fork the Sentinel Policy Repository
Start by forking the HashiCorp Sentinel policy repository into your GitHub account. This gives you a local copy to customize and connect to Terraform Cloud.
Review Sentinel Policies
Below are two example policies from the repository.1. Enforce Mandatory Tags
This policy uses thetfplan-functions import to require that every AWS EC2 instance in the plan has a Name tag. The main rule fails if any instance is missing this tag.
2. Restrict EC2 Instance Types
This policy ensures only specific EC2 instance types (t2.micro, t2.small, t2.medium) are allowed. Any other type triggers a violation.
Define a Policy Set
Group your Sentinel policies in asentinel.hcl file at the repository root. Specify each policy and its enforcement level:
The hard-mandatory level cannot be bypassed. Any violation will block the run.

Connect the Policy Set to Terraform Cloud
- In Terraform Cloud, go to Settings → Policy sets.
- Click Connect new policy set, select GitHub (or your VCS), then choose your fork.
- Set Policy framework to Sentinel, give it a name (e.g., “AWS Global Policies”), add a description, and specify the path:
- Apply to All workspaces.
- Click Connect policy set.



Test Policy Enforcement in the UI
Trigger a new run in your workspace. After the plan stage, you’ll see Policy check:

Test Policy Enforcement via CLI
- Configure your backend for Terraform Cloud and run
terraform login. - Change the
instance_typeinterraform.auto.tfvarsto an unapproved value (e.g.,"m5.large"). - Execute:

Remediate and Re-Run
Update yourterraform.auto.tfvars to a compliant instance type and commit:
Additional Resources
Terraform Public Registry – Policy Library (Beta): Terraform Public Registry Policy Library (Beta)



