The latest Terraform policy agent adds an automated conversion step for teams that have built governance logic in Sentinel or Open Policy Agent (OPA). Instead of manually re‑authoring each rule, the agent ingests .sentinel or .rego files, produces equivalent .policy.hcl files, generates test suites, and outputs a detailed conversion report. The change matters because it lets AI, cloud, DevOps, and security engineers keep policy logic in the same language and toolchain they already use for infrastructure provisioning.
How the conversion workflow works
The agent runs as a Docker container pulled from Docker Hub. Users select a model provider—GitHub Copilot, Amazon Bedrock, or LiteLLM—to power the language‑model‑driven translation. The process follows three stages:
- Extract policy goals: The agent parses each input policy, distills its intent into plain‑language requirements, and presents them for review before any code is generated.
- Generate policy and tests: Based on the extracted goals, the agent creates a Terraform policy file (
.policy.hcl), a corresponding test file (.policytest.hcl), supporting Terraform configuration, and a conversion report that lists any limitations. - Validate and summarize: The generated tests are executed against the new policy, and the agent reports pass/fail results along with any known gaps.
Because the agent grounds its output in real provider schemas via the Terraform MCP server, the resulting policies can reference actual resource attributes and provider data sources.
Practical implications for engineering teams
Adopting the agent changes the policy lifecycle in several ways:
- Unified authoring: Engineers write and test policies in HCL, eliminating the need to maintain separate Sentinel or Rego codebases.
- Resource relationship checks: Terraform policy can directly evaluate how resources interact (e.g., ensuring every IAM role has an attached policy) using native Terraform graph data.
- External context integration: Provider data source lookups allow policies to incorporate organizational standards without custom scripting.
- Supply‑chain guardrails: Policies can block unapproved module or provider downloads, extending compliance into the build pipeline.
- Lifecycle awareness: Validation can occur before and after a deployment, using the actual state to confirm compliance throughout the resource lifecycle.
From an operational perspective, the agent does not publish any artifacts automatically; all output remains under the team's control. However, because the conversion relies on a language model, results can vary between runs, and generated tests only prove coverage for the scenarios the agent created—not full semantic equivalence.
Limitations and considerations
The conversion is intent‑based, not a line‑by‑line translation. Constructs that lack a direct Terraform policy equivalent are flagged in the conversion report and require manual adjustment. The agent has been validated against policies for AWS, Azure, and Google Cloud; other providers are supported via schema lookups but have less testing coverage, so engineers should review those conversions carefully.
Policy content is sent to the chosen model provider, so organizations must ensure the provider meets their data‑handling and security requirements. The agent also respects any mock files present in Sentinel policies, using them to enrich generated test scenarios.
Related CloudNinjas coverage: hands-on guides.
What This Means For Practitioners
Teams with an existing library of Sentinel or OPA rules can accelerate migration to Terraform policy by running the agent in a container, reviewing the plain‑language goal extraction, and validating the generated tests. Start with advisory enforcement to confirm behavior before switching to mandatory enforcement. Keep an eye on conversion reports for any flagged limitations, and treat the generated tests as a baseline rather than a final guarantee of parity. Ongoing evaluation should include periodic re‑runs as policies evolve and as model providers receive updates.

