Policy as code turns governance rules into reviewable, version-controlled Rego. The OPA Rego Generator writes a ready-to-use policy that iterates over a chosen Terraform resource type and flags violations such as missing tags or encryption settings. Instead of hand-writing the rule body and getting the input path wrong, you pick the package, rule kind, resource type and field, add a violation message, and receive valid Rego you can commit immediately. Writing Rego by hand is fiddly because the rule must iterate over a collection and reference the correct input path, and a single typo silently breaks enforcement.
You choose deny to block non-compliant infrastructure as a hard gate, or warn to surface violations without failing the run while policy is rolled out gradually. The output runs in Conftest against Terraform plan JSON or in OPA against any document that exposes resources under input.resource.