terraform-policy
Write, test, or convert Terraform Policy files (.policy.hcl, .policytest.hcl, Sentinel→tfpolicy).
Skill by hashicorpOfficial
Chalk Labs
Need help deploying terraform-policy?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/hashicorp-terraform-policy
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing, devops, writing, infrastructure-as-code
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/terraform-policy
What's inside
- Skill 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
- version: 0.1.0 · copyright: Copyright IBM Corp. 2026 · lifecycle-status: active
- Instructions
- 44 lines in SKILL.md · view on GitHub
Files (55)
- .gitignore
- README.md
- SKILL.md
- README.md · examples/
- README.md · examples/conversion/cloudfront-associated-with-waf/
- cloudfront-associated-with-waf.policy.hcl · examples/conversion/cloudfront-associated-with-waf/
- cloudfront-associated-with-waf.sentinel · examples/conversion/cloudfront-associated-with-waf/
- README.md · examples/conversion/cloudtrail-server-side-encryption-enabled/
- cloudtrail-server-side-encryption-enabled.policy.hcl · examples/conversion/cloudtrail-server-side-encryption-enabled/
- cloudtrail-server-side-encryption-enabled.sentinel · examples/conversion/cloudtrail-server-side-encryption-enabled/
- README.md · examples/conversion/dms-endpoint-should-be-ssl-configured/
- dms-endpoint-should-be-ssl-configured.policy.hcl · examples/conversion/dms-endpoint-should-be-ssl-configured/
- dms-endpoint-should-be-ssl-configured.sentinel · examples/conversion/dms-endpoint-should-be-ssl-configured/
- README.md · examples/conversion/dms-endpoints-should-use-ssl/
- dms-endpoints-should-use-ssl.policy.hcl · examples/conversion/dms-endpoints-should-use-ssl/
- dms-endpoints-should-use-ssl.sentinel · examples/conversion/dms-endpoints-should-use-ssl/
- README.md · examples/conversion/ec2-network-acl-should-have-subnet-ids/
- ec2-network-acl-should-have-subnet-ids.policy.hcl · examples/conversion/ec2-network-acl-should-have-subnet-ids/
- ec2-network-acl-should-have-subnet-ids.sentinel · examples/conversion/ec2-network-acl-should-have-subnet-ids/
- README.md · examples/conversion/ec2-vpc-default-security-group-no-traffic/
- ec2-vpc-default-security-group-no-traffic.policy.hcl · examples/conversion/ec2-vpc-default-security-group-no-traffic/
- ec2-vpc-default-security-group-no-traffic.sentinel · examples/conversion/ec2-vpc-default-security-group-no-traffic/
- README.md · examples/conversion/efs-access-point-should-enforce-user-identity/
- efs-access-point-should-enforce-user-identity.policy.hcl · examples/conversion/efs-access-point-should-enforce-user-identity/
- efs-access-point-should-enforce-user-identity.sentinel · examples/conversion/efs-access-point-should-enforce-user-identity/
- README.md · examples/conversion/elasticache-redis-replication-group-encryption-at-transit-enabled/
- elasticache-redis-replication-group-encryption-at-transit-enabled.policy.hcl · examples/conversion/elasticache-redis-replication-group-encryption-at-transit-enabled/
- elasticache-redis-replication-group-encryption-at-transit-enabled.sentinel · examples/conversion/elasticache-redis-replication-group-encryption-at-transit-enabled/
- README.md · examples/conversion/elasticsearch-encrypted-at-rest/
- elasticsearch-encrypted-at-rest.policy.hcl · examples/conversion/elasticsearch-encrypted-at-rest/
- elasticsearch-encrypted-at-rest.sentinel · examples/conversion/elasticsearch-encrypted-at-rest/
- README.md · examples/conversion/elasticsearch-https-required/
- elasticsearch-https-required.policy.hcl · examples/conversion/elasticsearch-https-required/
- elasticsearch-https-required.sentinel · examples/conversion/elasticsearch-https-required/
- README.md · examples/conversion/elasticsearch-in-vpc-only/
- elasticsearch-in-vpc-only.policy.hcl · examples/conversion/elasticsearch-in-vpc-only/
- elasticsearch-in-vpc-only.sentinel · examples/conversion/elasticsearch-in-vpc-only/
- README.md · examples/conversion/eventbridge-custom-event-bus-should-have-attached-policy/
- eventbridge-custom-event-bus-should-have-attached-policy.policy.hcl · examples/conversion/eventbridge-custom-event-bus-should-have-attached-policy/
- eventbridge-custom-event-bus-should-have-attached-policy.sentinel · examples/conversion/eventbridge-custom-event-bus-should-have-attached-policy/
- README.md · examples/conversion/s3-block-public-access-bucket-level/
- s3-block-public-access-bucket-level.policy.hcl · examples/conversion/s3-block-public-access-bucket-level/
- s3-block-public-access-bucket-level.sentinel · examples/conversion/s3-block-public-access-bucket-level/
- README.md · examples/conversion/s3-bucket-should-have-object-lock-enabled/
- s3-bucket-should-have-object-lock-enabled.policy.hcl · examples/conversion/s3-bucket-should-have-object-lock-enabled/
- s3-bucket-should-have-object-lock-enabled.sentinel · examples/conversion/s3-bucket-should-have-object-lock-enabled/
- README.md · examples/conversion/secretsmanager-auto-rotation-enabled-check/
- secretsmanager-auto-rotation-enabled-check.policy.hcl · examples/conversion/secretsmanager-auto-rotation-enabled-check/
- secretsmanager-auto-rotation-enabled-check.sentinel · examples/conversion/secretsmanager-auto-rotation-enabled-check/
- README.md · examples/conversion/step-functions-state-machine-logging-enabled/
- step-functions-state-machine-logging-enabled.policy.hcl · examples/conversion/step-functions-state-machine-logging-enabled/
- step-functions-state-machine-logging-enabled.sentinel · examples/conversion/step-functions-state-machine-logging-enabled/
- tfpolicy-author.md · references/
- tfpolicy-test.md · references/
- verified-syntax.md · references/
SKILL.md (first lines)
# 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.4.x` and `0.5.x`. The `0.3.x` bullet below is baseline guidance that applies to every supported line. When a new minor ships, drop the oldest line and add the new one. Inline notes for versions earlier than `0.3.0` are retained only for older CLIs.
- If the CLI is `0.3.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. 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 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 strings outside Stack evaluations on 0.3.x and 0.4.x (`null` on 0.5.x+, see below). On 0.3.x only, the `no-op` operation does not exist: resource policies evaluate only resources that the run creates, updates, or deletes, and the default `operations` is `["create", "update"]`.
- If the CLI is `0.4.x` or newer, all `0.3.x` guidance still applies except the `operations` default, plus the `no-op` operation, which evaluates resources that the run leaves unchanged (the entire state). `operations` accepts `"create"`, `"update"`, `"delete"`, and `"no-op"`. For policies that do not reference `prior_attrs`, the default `operations` is now `["create", "update", "no-op"]`, so omitting it evaluates every resource in state. Use `operations = ["create", "update"]` to evaluate only changed resources. `no-op` exposes the existing values through `attrs`, and `prior_attrs` is unavailable. `delete` cannot be combined with `create` or `no-op` (`["update", "delete"]` is valid), and `prior_attrs` policies must set `operations` explicitly. Attrs-only policies (no `prior_attrs`) calling `core::getresources` whose `operations` omit `no-op` load with a warning; do not add `no-op` to a `prior_attrs` policy, which fails validation. In tests, set `meta.operation = "no-op"` explicitly because it is never inferred (see [tfpolicy-author](references/tfpolicy-author.md#operation-scoping-and-prior_attrs) and [tfpolicy-test](references/tfpolicy-test.md#testing-operation-aware-policies)).
- If the CLI is `0.5.x` or newer, all `0.4.x` guidance still applies, with two changes. (1) Absent `meta` attributes are exposed as `null` instead of an empty string: `meta.alias` (no alias), `meta.version` (no version specified, including modules), and `meta.tfe_stack.deployment_group` / `deployment_name` / `stack_name` (workspace evaluations or not set). `meta.tfe_workspace.tags` is still an empty map. Passing `null` to a function such as `core::semverconstraint`, or interpolating it into a string such as `error_message`, fails, and `&&` does not short-circuit, so guard with a conditional: `meta.version != null ? core::semverconstraint(meta.version, ">= 2.0.0") : false`. Equality checks are null-safe (`meta.alias == "secondary"` is `false` when there is no alias), but checks like `meta.tfe_stack.stack_name == ""` no longer match (use `== null`). (2) `prior_attrs` is rejected at parse time in `provider_policy` and `module_policy` blocks; it is valid only in `resource_policy` (update and delete operations). Use `attrs.` for provider attributes (see [tfpolicy-author](references/tfpolicy-author.md#meta-attributes-nullable-on-050)).
- If the CLI version is unknown, ask the user to check it first or provide guidance that clearly distinguishes the `0.3.x`, `0.4.x`, and `0.5.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, MPL-2.0.
More from hashicorp/agent-skills
- 0.777score
provider-configuration
hashicorpOfficial
Implement Terraform provider configuration and authentication with the Plugin Framework: provider schema for credentials (Optional + Sensitive attributes)…
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-docs
hashicorpOfficial
Create, update, and review Terraform provider documentation for Terraform Registry using HashiCorp-recommended patterns, tfplugindocs templates, and schema…
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-test-patterns
hashicorpOfficial
Terraform provider acceptance test patterns using terraform-plugin-testing with the Plugin Framework.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-framework-migration
hashicorpOfficial
Migrate Terraform provider resources and data sources from Plugin SDKv2 to the Plugin Framework: muxing both plugins in one provider (terraform-plugin-mux…
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
terraform-search-import
hashicorpOfficial
Discover existing cloud resources using Terraform Search queries and bulk import them into Terraform management.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
terraform-test
hashicorpOfficial
Comprehensive guide for writing and running Terraform tests.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
terraform-stacks
hashicorpOfficial
Comprehensive guide for working with HashiCorp Terraform Stacks.
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
push-to-registry
hashicorpOfficial
Push Packer build metadata to HCP Packer registry for tracking and managing image lifecycle.
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
aws-ami-builder
hashicorpOfficial
Build Amazon Machine Images (AMIs) with Packer using the amazon-ebs builder.
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
windows-builder
hashicorpOfficial
Build Windows images with Packer using WinRM communicator and PowerShell provisioners.
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
new-terraform-provider
hashicorpOfficial
Use this when scaffolding a new Terraform provider with the Plugin Framework: workspace layout, go module setup, provider server main.go, and a provider.go…
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
provider-ephemeral-resources
hashicorpOfficial
Implement Terraform provider ephemeral resources with the Plugin Framework: the Open/Renew/Close lifecycle, ephemeral schema design, registration via…
SkillBFreshness: B★ 907Claude Code +9
Compare and alternatives
Featured in
Signals
- Stars
- 907
- Forks
- 134
- Open issues
- 12
- Last commit (this folder)
- Sep 28, 2026 (1 month ago)
- Last release
- Aug 4, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 0.1.0
- License
- MPL-2.0
- Repository
- github.com/hashicorp/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from hashicorp
- 0.821score
Terraform
hashicorpOfficial
Generate more accurate Terraform and automate workflows for HCP Terraform and Terraform Enterprise
ConnectorAFreshness: ALocal★ 1.6KClaude Code +5 - 0.777score
terraform-stacks
hashicorpOfficial
Comprehensive guide for working with HashiCorp Terraform Stacks.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-configuration
hashicorpOfficial
Implement Terraform provider configuration and authentication with the Plugin Framework: provider schema for credentials (Optional + Sensitive attributes)…
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-docs
hashicorpOfficial
Create, update, and review Terraform provider documentation for Terraform Registry using HashiCorp-recommended patterns, tfplugindocs templates, and schema…
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
terraform-search-import
hashicorpOfficial
Discover existing cloud resources using Terraform Search queries and bulk import them into Terraform management.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-framework-migration
hashicorpOfficial
Migrate Terraform provider resources and data sources from Plugin SDKv2 to the Plugin Framework: muxing both plugins in one provider (terraform-plugin-mux…
SkillBFreshness: B★ 907Claude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get terraform-policy running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
terraform-policy skill. Agent Mart. https://agentmart.dev/skills/hashicorp-terraform-policy (last updated 2026-10-24)