tf-policy

Enforces Terraform policy rules on plans to block non-compliant infrastructure changes.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/hashi-demo-lab/terraform-agentic-workflows-demo09 --skill tf-policy
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tf-policy
Source: https://github.com/hashi-demo-lab/terraform-agentic-workflows-demo09/tree/main/.claude/skills/tf-policy
Command: npx skills add https://github.com/hashi-demo-lab/terraform-agentic-workflows-demo09 --skill tf-policy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Terraform policy as code provides a single source of truth for validating and constraining Terraform configurations. tf-policy defines the standard blocks, evaluation semantics, and tooling references to ensure infrastructure changes meet governance and compliance requirements before they are deployed.

Core Features & Use Cases

  • Policy blocks: Supports resource_policy, provider_policy, and module_policy to express guards across resources, providers, and modules.
  • Testing & evaluation: Uses .policytest.hcl mocks with meta, attrs, and prior_attrs to validate policy behavior across lifecycle stages.
  • Enforcement levels & lifecycle: Enables advisory or mandatory policies with operation-scoped applicability and evaluation stages for setup/plan/apply.
  • Documentation reference: Centralizes policy definitions and semantics to map compliance baselines to tfpolicy syntax.

Quick Start

Create a sample tf-policy resource_policy and validate it with tfpolicy test against a mock plan.

Frequently Asked Questions about tf-policy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce compliance guardrails on Terraform plans before deployment?▼

Terraform policy-as-code validates configurations by defining standard blocks like resource_policy, provider_policy, and module_policy to constrain deployments. It ensures infrastructure changes meet governance requirements before deployment by applying guards across resources, providers, and modules.

How do I test Terraform policy definitions against mock plans?▼

You test Terraform policy definitions by using .policytest.hcl files with meta, attrs, and prior_attrs mocks. This validates policy behavior across lifecycle stages like setup, plan, and apply using deterministic evaluation inputs.

What is the difference between advisory and mandatory policy enforcement in Terraform?▼

Terraform policy enforcement levels allow advisory or mandatory rules with operation-scoped applicability across setup, plan, and apply stages. This lets you choose whether policies warn or block non-compliant infrastructure changes during deployment.

Does policy-as-code work with Terraform modules and providers?▼

Yes, policy-as-code supports module_policy and provider_policy block types alongside resource_policy to express guards across resources, providers, and modules. This allows you to enforce compliance constraints across your entire Terraform infrastructure stack.

How do I map compliance baselines to Terraform policy syntax?▼

You map compliance baselines by centralizing policy definitions in .policy.hcl files using resource_policy, provider_policy, and module_policy blocks. Meta and input local attributes enable deterministic evaluation to align compliance requirements with policy syntax.