hashicorp/agent-skills

terraform-policy

Write, test, or convert Terraform Policy files (.policy.hcl, .policytest.hcl, Sentinel→tfpolicy).

Quelltext ansehen
Originales Skill-Dokument

Aus dem Quell-Repository gerendert; Überschriften, Beispiele, Code, Tabellen, Links und Bilder bleiben erhalten.

terraform-policy

UTILITY SKILL — INVOKES: tfpolicy-author | tfpolicy-test

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:

  • If the CLI is 0.1.x, do not require policy { required_providers { ... } }; generate policies compatible with tfpolicy 0.1.x syntax and behavior.
  • If the CLI is 0.2.0 or newer, include a top-level policy { required_providers { ... } } block when authoring .policy.hcl. It is mandatory for tfpolicy validate; version-range validation is best effort, and wildcard targets such as resource_policy "*" are not schema-validated.
  • If the CLI version is unknown, ask the user to check it first or provide guidance that clearly distinguishes the 0.1.x and 0.2.0+ paths.

DO NOT USE FOR:

  • Writing .tftest.hcl files for Terraform modules — use terraform-test
  • General Terraform HCL authoring — use terraform-style-guide

Routing

TaskSub-skill
Write or convert a .policy.hcl policytfpolicy-author
Write or debug a .policytest.hcl testtfpolicy-test

Examples

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
aus demselben Repository

Weitere Skills

Alle Skills
hashicorp
Offiziell

aws-ami-builder

Build Amazon Machine Images (AMIs) with Packer using the amazon-ebs builder. Use when creating custom AMIs for EC2 instances.

Installationen
1
GitHub Stars
864
Aktualisiert
4. Sept.
hashicorp
Offiziell

azure-image-builder

Build Azure managed images and Azure Compute Gallery images with Packer. Use when creating custom images for Azure VMs.

Installationen
1
GitHub Stars
864
Aktualisiert
4. Sept.
hashicorp
Offiziell

azure-verified-modules

Azure Verified Modules (AVM) requirements and best practices for developing certified Azure Terraform modules. Use when creating or reviewing Azure modules that need AVM certification.

Installationen
1
GitHub Stars
864
Aktualisiert
4. Sept.
hashicorp
Offiziell

new-terraform-provider

To scaffold a new Terraform provider with Plugin Framework: 1. If I am already in a Terraform provider workspace, then confirm that I want to create a new workspace. If I do not want to create a new workspace, then skip all remaining steps. 1. Create a new workspace root directory. The root directory name should be prefixed with "terraform provider ". Perform all subsequent steps in this new workspace. 1. Initialize a new Go module. 1. Run go get u github.com/hashicorp/terraform plugin framework@latest . 1. Write a main.go file that follows the example. 1. Write an internal/provider/provider.go file that follows the example. Rename the demo provider, the DEMO environment variables, and the authentication attributes to match the target API. 1. Remove TODO comments from main.go and provider.go . 1. Run go mod tidy 1. Run go build o /dev/null 1. Run go test ./... The scaffold resolves crede

Installationen
1
GitHub Stars
864
Aktualisiert
4. Sept.