terraform-policy
This skill helps write, test, and convert Terraform Policy files in .policy.hcl and .policytest.hcl formats, and convert Sentinel policies to Terraform Policy…
Identity proven by GitHub's verified organisation badge (hashicorp)
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- MPL-2.0 (copyleft)
- Pin
- f706481pinned Oct 9, 2026
- Context cost
- about 920 tokenswhen the skill loads
- GitHub stars
- 890on hashicorp/agent-skills
- Scripts
- None found
What it does
“Write, test, or convert Terraform Policy files (.policy.hcl, .policytest.hcl, Sentinel→tfpolicy). Triggers: policy.hcl, policytest, convert sentinel, tfpolicy, write a policy.”
Generated summary from the skill's own text
This skill helps write, test, and convert Terraform Policy files in .policy.hcl and .policytest.hcl formats, and convert Sentinel policies to Terraform Policy syntax. It routes authoring tasks to tfpolicy-author and testing tasks to tfpolicy-test, adjusting guidance based on the installed tfpolicy CLI version.
When to use it
- Creating a new .policy.hcl policy from requirements or descriptions
- Converting existing Sentinel policies to Terraform Policy format
- Writing or debugging .policytest.hcl test files for policies
- Migrating a Sentinel policy library to Terraform Policy
When not to
- Writing .tftest.hcl files for Terraform modules, use terraform-test instead
- General Terraform HCL authoring, use terraform-style-guide instead
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add hashicorp/agent-skills --skill terraform-policyInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install hashicorp/agent-skills terraform-policy@f706481af9b8fedb66de909f6243ad29601afa0cInstalls the commit we checked (f706481).
Copy by hand
Download the folder at f706481 and put it in .claude/skills/terraform-policy for Claude Code and in .agents/skills/terraform-policy for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "terraform-policy" by HashiCorp. Source, pinned to commit f706481af9b8fedb66de909f6243ad29601afa0c: https://github.com/hashicorp/agent-skills/tree/f706481af9b8fedb66de909f6243ad29601afa0c/plugins/terraform/skills/terraform-policy 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/terraform-policy/ for Claude Code and .agents/skills/terraform-policy/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/hashicorp/terraform-policy
SKILL.md at the pin
---
name: terraform-policy
description: "Write, test, or convert Terraform Policy files (.policy.hcl, .policytest.hcl, Sentinel→tfpolicy). Triggers: policy.hcl, policytest, convert sentinel, tfpolicy, write a policy."
license: MPL-2.0
metadata:
lifecycle-status: active
copyright: Copyright IBM Corp. 2026
version: "0.1.0"
---
# terraform-policy
**UTILITY SKILL** — INVOKES: [tfpolicy-author](references/tfpolicy-author.md) | [tfpolicy-test](references/tfpolicy-test.md)
## USE FOR:
- Writing a new `.policy.hcl` policy from a description or requirement
- Converting a `.sentinel` policy to Terraform Policy
- Writing or debugging a `.policytest.hcl` test file
- Migrating a Sentinel policy library to Terraform Policy
Before giving authoring or testing instructions, check the installed `tfpolicy` CLI version and tailor guidance accordingly. This skill maintains guidance for the two most recent minor lines, `0.2.x` and `0.3.x`; when a new minor ships, drop the oldest line and add the new one.
- If the CLI is `0.2.x` (baseline), include a top-level `policy { required_providers { ... } }` block when authoring `.policy.hcl` files containing resource or provider policies. It is mandatory for `tfpolicy validate`; version-range validation is best effort, and wildcard targets such as `resource_policy "*"` are not schema-validated. `tfpolicy test` does not preflight mocked `attrs`/`prior_attrs` against provider schemas, `core::alltrue`/`core::anytrue` do not exist, and, only in this `0.2.x` line, mock `resource {}` blocks may omit `attrs`/`prior_attrs` entirely.
- If the CLI is `0.3.x` or newer, the other guidance above still applies, but the `0.2.x` allowance for omitting resource state does not: every mock `resource {}` block in `.policytest.hcl` files must declare `attrs` or `prior_attrs`; if both evaluate to empty, the test case is skipped (`provider {}` and `module {}` mocks are unaffected) (see [tfpolicy-test](references/tfpolicy-test.md#every-resource--mock-must-declare-a-non-empty-state-block-tfpolicy-030)). `tfpolicy test` reuses the target `.policy.hcl`'s existing top-level `policy { required_providers { ... } }` block (there is no separate `.policytest.hcl`-level declaration) to validate provider, resource, and data-source policies and `core::getdatasource()`/`core::getresources()` arguments against resolved provider schemas before any test runs, failing the whole run on a schema mismatch (see [tfpolicy-test](references/tfpolicy-test.md#test-execution-behavior)). `core::alltrue(list)` and `core::anytrue(list)` are also available — prefer them over the `core::length()` list-comprehension workaround (see [tfpolicy-author](references/tfpolicy-author.md#core-functions--common-idioms)). `meta.tfe_stack` and `meta.tfe_workspace.tags` are available to resource, provider, and module policies; Stack fields are empty outside Stack evaluations.
- If the CLI version is unknown, ask the user to check it first or provide guidance that clearly distinguishes the `0.2.x` and `0.3.x` paths.
## DO NOT USE FOR:
- Writing `.tftest.hcl` files for Terraform modules — use `terraform-test`
- General Terraform HCL authoring — use `terraform-style-guide`
## Routing
| Task | Sub-skill |
|------|-----------|
| Write or convert a `.policy.hcl` policy | [tfpolicy-author](references/tfpolicy-author.md) |
| Write or debug a `.policytest.hcl` test | [tfpolicy-test](references/tfpolicy-test.md) |
## Examples
- "Block EC2 instances without encryption" → [tfpolicy-author](references/tfpolicy-author.md)
- "Convert this Sentinel policy to tfpolicy" → [tfpolicy-author](references/tfpolicy-author.md)
- "Write a policytest for my EBS policy" → [tfpolicy-test](references/tfpolicy-test.md)
## Troubleshooting
- **Wrong skill triggered?** Load the sub-skill directly from the routing table above.
```bash
npx skills add hashicorp/agent-skills/terraform/terraform-policy/skills/tfpolicy-author
npx skills add hashicorp/agent-skills/terraform/terraform-policy/skills/tfpolicy-test
```
From hashicorp/agent-skills at f706481, shown as plain text under its license: MPL-2.0 (copyleft). The license text is in plugins/terraform/skills/terraform-policy/SKILL.md.
View SKILL.md on GitHub at f706481Files
- SKILL.md4.0 KB · 80d14e922364
- .gitignore29 B · 53f0c100a33a
- README.md2.8 KB · b3ac71f05989
- examples/
- README.md2.6 KB · 0907dc196a01
- conversion/
- cloudfront-associated-with-waf/
- README.md871 B · 0db50b97832e
- cloudfront-associated-with-waf.policy.hcl589 B · 32462493a912
- cloudfront-associated-with-waf.sentinel1.6 KB · 03ef3243452e
- cloudtrail-server-side-encryption-enabled/
- README.md846 B · b4b775bc4adf
- cloudtrail-server-side-encryption-enabled.policy.hcl512 B · afc4804e1ea5
- cloudtrail-server-side-encryption-enabled.sentinel1.5 KB · bf012527a3c8
- dms-endpoint-should-be-ssl-configured/
- README.md872 B · f37a8e239336
- dms-endpoint-should-be-ssl-configured.policy.hcl516 B · 0b16fb23e36b
- dms-endpoint-should-be-ssl-configured.sentinel1.5 KB · bb7576142e5b
- dms-endpoints-should-use-ssl/
- README.md800 B · 43d445514b68
- dms-endpoints-should-use-ssl.policy.hcl579 B · 5c9e145e4337
- dms-endpoints-should-use-ssl.sentinel1.4 KB · 7413174edc26
- ec2-network-acl-should-have-subnet-ids/
- README.md970 B · 2da9954728e4
- ec2-network-acl-should-have-subnet-ids.policy.hcl1.0 KB · 093fd998d51c
- ec2-network-acl-should-have-subnet-ids.sentinel2.9 KB · 6f9065377faa
- ec2-vpc-default-security-group-no-traffic/
- README.md1.1 KB · cae1492ca099
- ec2-vpc-default-security-group-no-traffic.policy.hcl865 B · 8c4f7842a455
- ec2-vpc-default-security-group-no-traffic.sentinel3.7 KB · a67323d87286
- efs-access-point-should-enforce-user-identity/
- README.md727 B · ea22ae2c5cd8
- efs-access-point-should-enforce-user-identity.policy.hcl448 B · d60d2ab084e7
- efs-access-point-should-enforce-user-identity.sentinel1.3 KB · f7ba102efad5
- elasticache-redis-replication-group-encryption-at-transit-enabled/
- README.md777 B · 9d211dc3d9bf
- elasticache-redis-replication-group-encryption-at-transit-enabled.policy.hcl547 B · aa00818be52c
- elasticache-redis-replication-group-encryption-at-transit-enabled.sentinel1.5 KB · 460c04567ae6
- elasticsearch-encrypted-at-rest/
- README.md734 B · 2f332ce9d7af
- elasticsearch-encrypted-at-rest.policy.hcl584 B · 1466b60bfada
- elasticsearch-encrypted-at-rest.sentinel1.6 KB · 1769ea7859bb
- elasticsearch-https-required/
- README.md904 B · b291b58730e7
- elasticsearch-https-required.policy.hcl1.1 KB · eabe03b52103
- elasticsearch-https-required.sentinel2.4 KB · 91366427ef59
- elasticsearch-in-vpc-only/
- README.md890 B · 71ece548a3e2
- elasticsearch-in-vpc-only.policy.hcl589 B · 1a7ddfa53827
- elasticsearch-in-vpc-only.sentinel1.9 KB · 523e3196f104
- eventbridge-custom-event-bus-should-have-attached-policy/
- README.md1.1 KB · fa63a88da88b
- eventbridge-custom-event-bus-should-have-attached-policy.policy.hcl845 B · ccccf9909353
- eventbridge-custom-event-bus-should-have-attached-policy.sentinel2.1 KB · 00702067c7b0
- s3-block-public-access-bucket-level/
- README.md1.1 KB · 928a996543a9
- s3-block-public-access-bucket-level.policy.hcl1.2 KB · ac6e9becbb43
- s3-block-public-access-bucket-level.sentinel3.3 KB · 7afc9dd94c89
- s3-bucket-should-have-object-lock-enabled/
- README.md975 B · c52fdde16a7a
- s3-bucket-should-have-object-lock-enabled.policy.hcl1.0 KB · 35df8b69cc62
- s3-bucket-should-have-object-lock-enabled.sentinel2.9 KB · a76cd0917aae
- secretsmanager-auto-rotation-enabled-check/
- README.md955 B · 32a7172f87d6
- secretsmanager-auto-rotation-enabled-check.policy.hcl867 B · 4abb6f1fbc8f
- secretsmanager-auto-rotation-enabled-check.sentinel2.3 KB · aed6232049c0
- step-functions-state-machine-logging-enabled/
- README.md778 B · f92554ddc004
- step-functions-state-machine-logging-enabled.policy.hcl724 B · 02694155f259
- step-functions-state-machine-logging-enabled.sentinel1.6 KB · ca2325e425f1
- references/
- tfpolicy-author.md100 KB · 86f8e1eb4227
- tfpolicy-test.md46 KB · 791d1472866d
- verified-syntax.md102 KB · 5f2aedcb42f5
55 files, 318 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at f706481More from HashiCorp
aws-ami-builder
This skill enables the agent to build custom Amazon Machine Images using Packer's amazon-ebs builder.
Claude Code, Codex, Cursor +4 · about 870 tokens · pinned 6 days ago
azure-image-builder
This skill uses Packer's Azure ARM builder to create custom managed images and Compute Gallery images in Azure.
Claude Code, Codex, Cursor +4 · about 1K tokens · pinned 6 days ago
azure-verified-modules
This skill provides comprehensive requirements and best practices for developing Azure Terraform modules that meet Azure Verified Modules (AVM) certification…
Claude Code, Codex, Cursor +4 · about 4K tokens · pinned 6 days ago
new-terraform-provider
Scaffolds a new Terraform provider using the Plugin Framework by creating workspace structure, initializing a Go module, and generating main.go and…
Contains scripts
Claude Code, Codex, Cursor +3 · about 330 tokens · pinned 6 days ago
provider-actions
This skill guides implementing Terraform Actions, imperative operations that execute at provider lifecycle events using the Plugin Framework.
Claude Code, Codex, Cursor +4 · about 4.2K tokens · pinned 6 days ago
provider-configuration
This skill guides implementing Terraform provider authentication using the Plugin Framework, covering provider schema design, credential provider chains that…
Claude Code, Codex, Cursor +4 · about 3.3K tokens · pinned 6 days ago
Related in Cloud and DevOps
google-agents-cli-deploy
Deploys agents built with agents-cli to Agent Runtime, Cloud Run, or GKE using a tested CLI pipeline.
by GoogleOfficial publisher
Claude Code, Codex, Cursor +4 · about 7.4K tokens · pinned 6 days ago
azure-to-aws
This skill guides agents through migrating Azure workloads to AWS across six phases: discovering Azure resources from Terraform, live CLI, app code, and…
by Amazon (AWS)Official publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 4.3K tokens · pinned 6 days ago
gcp-to-aws
Migrates workloads from Google Cloud Platform to AWS, including AI and agentic applications from any provider.
by Amazon (AWS)Official publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 14.3K tokens · pinned 6 days ago
heroku-to-aws
This skill guides migration of applications and databases from Heroku to AWS services like Elastic Beanstalk, RDS, ElastiCache, and MSK.
by Amazon (AWS)Official publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 7K tokens · pinned 6 days ago
tf-best-practices
This skill provides authoring rules for generating secure AWS Terraform and runs a read-only policy gate to verify generated code against those rules.
by Amazon (AWS)Official publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 3K tokens · pinned 6 days ago
provider-ephemeral-resources
Implement Terraform ephemeral resources using the Plugin Framework to handle sensitive values like tokens and credentials that must never be written to state…
by HashiCorpOfficial publisher
Claude Code, Codex, Cursor +4 · about 2.1K tokens · pinned 6 days ago