Table of Contents
Open Table of Contents
The review comment is not a control
A senior engineer writes “please don’t open 0.0.0.0/0” on a Terraform pull request. The author fixes that file. A second change, opened from a module the reviewer did not expand, still publishes an S3 bucket. Someone else kubectl applys a privileged pod from a laptop. The ticket said the rule. The ticket did not run.
That is the gap policy as code is for. The rule has to be data a machine can evaluate, in the same place the change is about to become real: the plan, the admission request, or the authorization call. A wiki page, a Slack norm, and a careful reviewer are inputs to that rule. They are not the control.
This post is for infrastructure engineers who already ship Terraform, OpenTofu, Kubernetes, or CloudFormation and are tired of re-explaining the same guardrail. It covers what the control actually is, which official languages exist, which companies sell a control plane around them, a pinned install, a workflow, runnable examples, and one named production deployment with the source of every number.
Versions below are a snapshot from 17 November 2026. Re-check the release page before you pin them in a pipeline.
What policy as code is
Policy as code is a versioned decision function.
You give an engine two inputs: the proposed change (a Terraform plan, a Kubernetes admission review, a CloudFormation template, an API request) and the rule. The engine returns a decision: allow, deny, or warn, plus a message a human can act on. The service in front of the engine enforces that decision. Open Policy Agent describes the split in its README: you write rules, a service queries OPA, OPA returns allow or deny, and the service accepts or rejects the request. The policy does not SSH into the account and fix the resource. Something else has to refuse the apply.
Three properties make it engineering instead of a linter costume:
- The rule is a file in Git. Review, history, and rollback apply to it.
- The same rule can run before merge and again at the last gate, so a path that skipped CI still hits it.
- The decision is a log. An auditor can see which rule fired. A green pipeline with no policy run is not evidence.
It is not one product. Rego, Sentinel, Cedar, Guard, and Kyverno’s CEL policies answer overlapping questions with different inputs. Picking “the policy tool” before naming the question is how teams buy three control planes and still miss kubectl apply.
The proposal: three gates, two questions
Infra teams usually mash two questions into one review:
- Is this change allowed? Tags, encryption, public exposure, privilege, image registry, cost ceiling.
- Is this caller allowed to make it? Who may plan production, who may override a soft failure, who may read a secret.
Answer them with different engines. Do not teach Cedar to parse a Terraform plan, and do not teach a tag policy to be your IAM.
For question 1, put the same intent at three gates. Fail closed only after the signal is clean.
| Gate | When it runs | What it can see | What it misses |
|---|---|---|---|
| Author | Editor, pre-commit, opa test | The fixture you wrote | Everything not in that fixture |
| Plan | CI on terraform show -json, a template, or a Helm render | Configured values in the plan or manifest | Provider-computed fields, console clicks, kubectl apply from a laptop |
| Admission | Cluster webhook, or a post-apply scan | The object the API server actually received | Changes that never touch that API |
HashiCorp’s policy framework comparison states the plan-gate limit directly: Sentinel and OPA on HCP Terraform evaluate a static snapshot of the plan. They cannot call a data source at policy time, and they are not re-run against live state after apply. A tag that the provider fills in during apply is invisible to that check. That is why the third gate exists.
Rollout, not a big-bang deny:
- Write one rule for a failure you already had. Not a 200-policy pack.
- Unit-test it.
- Run it as advisory or Audit. Publish the failures.
- Fix the noise. Exceptions get an owner and an expiry in Git, not a Slack thread.
- Flip that one rule to deny. Leave the rest advisory.
Question 2 belongs on the API that performs the apply: cloud IAM, plus a policy language such as Cedar where you are building the authorization service yourself. HCP Terraform already has its own permission model; Sentinel’s enforcement level is how you express “must pass unless someone with override permission proceeds.” Those levels are not inside the policy file. HashiCorp documents them as advisory, soft-mandatory, and hard-mandatory, configured on the policy, not known to the policy body. See Enforcement levels.
Official languages
These are the languages the vendors document, not a ranking.
| Language | Engine | Official home | What it is for |
|---|---|---|---|
| Rego | Open Policy Agent | Policy language | General decisions over JSON: plans, admission, APIs. OPA is a CNCF graduated project; the graduation announcement is dated 4 February 2021. |
| Sentinel | Sentinel, embedded in HashiCorp products | Sentinel docs | Embedded policy for Terraform, Vault, and Consul. Not a standalone linter you point at a Git repo. |
| HCL | Terraform policy | Policy enforcement overview | HashiCorp’s native policy framework on HCP Terraform. Same language as Terraform configuration. Applies to workspaces and Stacks. Sentinel and OPA policy sets, on that platform, support workspaces only. |
| CEL, in Kyverno YAML | Kyverno | kyverno/policies | Kubernetes admission, mutation, generation, cleanup, image verification. Current library policies are policies.kyverno.io/v1 resources, not legacy ClusterPolicy. |
| Cedar | Cedar, AWS Verified Permissions | Syntax guide | Authorization. permit and forbid. A forbid wins. It does not lint a .tf file. |
| Guard | CloudFormation Guard | Guard README | Declarative checks over JSON or YAML: templates, Terraform JSON, Kubernetes manifests, AWS Config items. |
| TypeScript, JavaScript, Python, or Rego | Pulumi Policies | Pulumi policy-as-code docs | Policies run as analyzer plugins against Pulumi resources. A policy written in one of those languages applies to Pulumi programs written in any language. |
| Python checks plus a built-in library | Checkov | Installing Checkov | Static IaC scan. Useful on day one. It is a scanner with a policy library, not the language you standardize the company on. |
Rego v1, which OPA 1.x uses, requires the if keyword between a rule head and its body. The keyword reference is the spec. Examples copied from 2023 blog posts often fail on a current OPA for that reason alone.
Kyverno’s maintained samples have moved. The policies README says samples use CEL ValidatingPolicy, MutatingPolicy, GeneratingPolicy, DeletingPolicy, and ImageValidatingPolicy, require Kyverno 1.17 or later, and that legacy ClusterPolicy samples have been removed. Do not start a new cluster on the old YAML pattern.
What companies already sell
The open engine and the hosted control plane are different purchases. The engine evaluates. The product usually adds distribution, a UI, decision logs, exceptions, and someone to call.
| Product | Who sells it | What you are actually buying | Source |
|---|---|---|---|
| OPA, Gatekeeper, Conftest | CNCF projects, not a vendor | The engines. Gatekeeper is the Kubernetes admission integration. Conftest runs Rego on config files in CI. | OPA README, release tags below |
| Styra Declarative Authorization Service | Styra, the company behind OPA | A commercial control plane for OPA: policy lifecycle, distribution, audit. A vendor case study names Capital One as a customer. Treat that PDF as marketing. The public technical record is OPA’s ADOPTERS.md, which lists Capital One using OPA for Kubernetes admission (image registry allowlisting, labels, resource requirements, privileges) and points at a KubeCon US 2018 talk. | Vendor PDF, ADOPTERS.md |
| HCP Terraform and Terraform Enterprise | HashiCorp | Policy sets in Sentinel, Rego, or Terraform policy (HCL), scoped to the organization, projects, workspaces, Stacks, or tags. Failed policies can stop a run. | Manage policy sets |
| Nirmata | Nirmata | Commercial management around Kyverno. The Chase UK write-up below is theirs; the conference session is the independent listing. | Case studies |
| Prisma Cloud, with Checkov | Palo Alto Networks | Checkov is the open-source scanner (bridgecrewio/checkov). Prisma Cloud is the commercial service that can run Checkov with enforcement rules and an API key. | Prisma Cloud Checkov docs |
| Pulumi Policies | Pulumi | Policy packs in TypeScript, JavaScript, Python, or Rego, plus pre-built packs, on pulumi preview and pulumi up. | Pulumi docs |
| Policy Controller | Google Cloud | Gatekeeper, plus multi-cluster distribution, Cloud Logging, and console status. Google’s docs recommend it over running Gatekeeper yourself when you want those extras. | GKE Gatekeeper guide |
| Azure Policy, deployed by EPAC | Microsoft | Azure Policy is the control. Enterprise Azure Policy as Code is Microsoft’s desired-state deployment tool for it. EPAC wants to be the source of truth for policy inside a chosen management-group scope. | EPAC start-implementing doc |
| Verified Permissions | AWS | A managed store for Cedar policies. CloudFormation Guard is the separate open-source CLI for template and config checks. Do not conflate them. | Verified Permissions policy resource, Guard user guide |
Two operational limits that belong in the buying conversation, both from HashiCorp’s policy-set docs: policy checks support Sentinel versions up to 0.40.x and do not support newer Sentinel versions, and OPA policy sets on HCP Terraform run as policy evaluations rather than the older policy-check type. Read Manage policy sets before you copy a Sentinel file from 2021 into a new organization.
How to install
Prerequisites for the path that does not need a cluster:
- Linux x86_64 for the pinned archives below. Other architectures have sibling assets on the same release. Do not run the Linux binary on a Mac.
curl,tar,sha256sum.- A working directory you can throw away. None of this installs a cluster.
Pinned releases, checked against each project’s GitHub release on 17 November 2026:
| Tool | Tag | Published |
|---|---|---|
| OPA | v1.22.4 | 12 November 2026 |
| Conftest | v0.71.1 | 6 October 2026 |
| Kyverno | v1.20.0, Helm chart 3.10.0 shipped in that release | 12 November 2026 |
| Kyverno CLI | kyverno-cli_v1.20.0_linux_x86_64.tar.gz on the same release | 12 November 2026 |
| Checkov | 3.4.5 | 12 November 2026 |
| CloudFormation Guard | 3.2.2 | 16 November 2026 |
| Gatekeeper | v3.23.1 | 27 August 2026 |
OPA and Conftest
The OPA static binary checksum below is the contents of opa_linux_amd64_static.sha256 from the v1.22.4 release.
OPA_VERSION=v1.22.4
curl -fsSL -o opa \
"https://github.com/open-policy-agent/opa/releases/download/${OPA_VERSION}/opa_linux_amd64_static"
echo "35e3b352e715e80624ead6c89930d8585f6f7d94cdc409eb2a9fe36620dcccba opa" | sha256sum -c -
chmod 755 opa
sudo mv opa /usr/local/bin/opa
opa version
Conftest’s install doc publishes checksums.txt next to the archive. Verify against that file from the same tag. Do not skip it because the version string looks right.
CONFTEST_VERSION=0.71.1
curl -fsSL -o "conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz" \
"https://github.com/open-policy-agent/conftest/releases/download/v${CONFTEST_VERSION}/conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz"
curl -fsSL -o checksums.txt \
"https://github.com/open-policy-agent/conftest/releases/download/v${CONFTEST_VERSION}/checksums.txt"
grep "conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz" checksums.txt | sha256sum -c -
tar -xzf "conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz" conftest
sudo mv conftest /usr/local/bin/conftest
conftest --version
The Conftest install variants, including the attestation check, are in docs/install.md.
First successful run. This fixture is intentionally incomplete.
mkdir -p policy
cat > policy/tags.rego << 'EOF'
package infra.tags
import rego.v1
required := {"owner", "env", "cost-center"}
deny contains msg if {
tags := object.get(input, "tags", {})
some tag in required
not tags[tag]
msg := sprintf("missing required tag %q", [tag])
}
test_deny_when_owner_missing if {
result := deny with input as {"tags": {"env": "prod", "cost-center": "sre"}}
count(result) == 1
}
test_allow_when_tags_complete if {
result := deny with input as {"tags": {
"owner": "platform",
"env": "prod",
"cost-center": "sre",
}}
count(result) == 0
}
EOF
cat > input.json << 'EOF'
{"tags": {"owner": "platform"}}
EOF
opa test policy/tags.rego -v
opa eval -d policy/tags.rego -i input.json 'data.infra.tags.deny'
opa test should report two passes. opa eval should return a set with missing required tag "env" and missing required tag "cost-center". If the binary rejects if or contains, you are not on OPA 1.x. Stop and check opa version before debugging the rule.
Kyverno, if the gate is the cluster
Kyverno’s install docs say to use Helm for production, to install into a dedicated namespace, and not to colocate it with other apps or with kube-system. Chart 3.10.0 installs app v1.20.0. The chart’s Kubernetes constraint, from those docs, is >=1.25.0-0. That is the chart’s install constraint, not a promise about every API you will write a policy for.
The Artifact Hub notes for chart 3.10.0 say installing or upgrading is blocked by default while legacy kyverno.io policy resources still exist, so you notice the loss of enforcement before the upgrade rather than after. Read that note before you point this chart at a cluster that already runs Kyverno. A fresh cluster does not have that block.
helm repo add kyverno https://kyverno.github.io/kyverno/
helm repo update
helm install kyverno kyverno/kyverno --version 3.10.0 \
-n kyverno --create-namespace \
--set admissionController.replicas=3 \
--set backgroundController.replicas=2 \
--set cleanupController.replicas=2 \
--set reportsController.replicas=2
kubectl get pods -n kyverno
First success is every controller pod Running, then a policy applied in Audit (next section) that reports a violation without deleting anything. Do not start with Deny on a cluster you did not build this morning.
Checkov, if you want a scanner in CI before you have written a single Rego rule:
pip install 'checkov==3.4.5'
checkov -d .
The pip method is the one documented in the Checkov install guide linked above. Guard 3.2.2 installs from its own release assets; the README’s install section is the source of truth, and Guard 2.0 and later are not compatible with Guard 1.0 rules.
How to use
After the CLI runs, the work is a loop, not a dashboard.
- Put policies in their own repo, or in a
policy/directory with CODEOWNERS that includes the people who will be paged when a deny is wrong. Platform writes the harness. Security can open the pull request. That split is the point of Chase UK’s migration, covered below. - One rule per failure mode. A rule called
best-practicesbecomes unreviewable. - Test the rule with
opa testbefore it sees a real plan. Conftest is the CI wrapper, not the test runner. - In CI, render the artifact the engine understands.
terraform plan -out=tfplan.binary
terraform show -json tfplan.binary > tfplan.json
conftest test tfplan.json -p policy/ --all-namespaces
terraform show -json puts resource_changes at the top of the document. Conftest feeds that document as input. The policy in the next section reads only that array. A real plan has more fields. Unknown values show up as after_unknown, not as the string you hoped the provider would write.
- Start advisory. In Conftest that is a
warnrule, or a pipeline that does not fail the job. In Kyverno the library standard isvalidationActions: [Audit]. In Sentinel the level is advisory, set outside the file. - Read the failures for a fixed window. Delete rules that only encode taste. Fix rules that fire on generated tags.
- Promote one rule to deny. Record the override path before you do it. A hard-mandatory rule with no break-glass becomes a Friday incident.
- Keep decision logs. OPA can emit them. Kyverno writes policy reports. HCP Terraform stores the policy check on the run. The log is the audit artifact. The absence of a failed job is not.
Exceptions are a second policy or a structured allowlist with an owner and an expiry, reviewed in the same pull request as the skip. A comment in the Terraform file is not an exception the engine can see.
Practice code
Four examples. The Rego and the Kyverno manifest are the ones to copy. Sentinel, Cedar, and Guard are included so the syntax is recognizable, with the official page as the runnable source.
Rego against a Terraform plan
Save as policy/terraform_tags.rego. The fixture under it is a reduced plan, enough to exercise the rule. It is not a full terraform show -json document.
package terraform.tags
import rego.v1
required_tags := {"owner", "env", "cost-center"}
deny contains msg if {
some change in input.resource_changes
change.mode == "managed"
some action in change.change.actions
action in {"create", "update"}
after := object.get(change.change, "after", {})
tags := object.get(after, "tags", {})
some tag in required_tags
not tags[tag]
msg := sprintf("%s missing required tag %q", [change.address, tag])
}
{
"resource_changes": [
{
"address": "aws_s3_bucket.logs",
"mode": "managed",
"type": "aws_s3_bucket",
"change": {
"actions": ["create"],
"after": {
"tags": {"env": "prod"}
}
}
}
]
}
opa eval -d policy/terraform_tags.rego -i tfplan.min.json 'data.terraform.tags.deny'
conftest test tfplan.min.json -p policy/terraform_tags.rego
Expect a deny naming aws_s3_bucket.logs and the missing tags. Two limits, both real: many AWS resources expose provider-merged tags on tags_all, and Azure resources often use a different attribute. A policy that only reads tags will pass a plan that is still untagged in the account. Cover the attributes your providers actually write, and do not pretend one rule spans AWS, Azure, and Google Cloud.
Blocking a prefix is the other shape teams need. Conftest’s own HCL example denies plans that change google_iam or google_container resources. The file is examples/hcl1/policy/base.rego. Use that pattern for “this workspace may not touch IAM,” and use the tag rule for “this workspace may touch IAM only if it is tagged.”
Kyverno ValidatingPolicy
This is the sample from the kyverno/policies README, which audits Pods missing an app label. It targets Kyverno 1.17 or later. The annotations are theirs. Audit is deliberate: applying a library policy should not take down a cluster you have not measured.
apiVersion: policies.kyverno.io/v1
kind: ValidatingPolicy
metadata:
name: require-app-label
annotations:
policies.kyverno.io/title: Require App Label
policies.kyverno.io/category: Best Practices
policies.kyverno.io/severity: medium
policies.kyverno.io/minversion: 1.17.0
kyverno.io/kubernetes-version: "1.30+"
policies.kyverno.io/subject: Pod
policies.kyverno.io/description: >-
Pods must have an app label identifying their application.
spec:
validationActions: [Audit]
evaluation:
background:
enabled: true
matchConstraints:
resourceRules:
- apiGroups: [""]
apiVersions: ["v1"]
operations: ["CREATE", "UPDATE"]
resources: ["pods"]
validations:
- expression: "has(object.metadata.labels) && 'app' in object.metadata.labels"
message: "An app label is required."
kubectl apply -f require-app-label.yaml
kubectl get validatingpolicy require-app-label
kubectl run nginx --image=nginx
Use a namespace that already allows that pod. Pod Security Admission can reject it for a different reason, and that failure is not this policy. In Audit, the pod is created. The success signal is the policy object present and a violation in Kyverno’s report for that pod, not a denied API call. Report CRD names have moved across Kyverno versions, including toward OpenReports, which is what the Chase UK session lists. Read the report with the command in the Kyverno version you installed, not from a 2023 snippet.
When that report matches what you meant to catch, change validationActions to Deny in a reviewed pull request and run the same kubectl run again. That second run should fail admission. The require-labels policy in the same library is the stricter variant: it requires app.kubernetes.io/name to be present and non-empty, and it declares policies.kyverno.io/minversion: 1.19.1.
Kyverno’s README is explicit that this does not replace Kubernetes ValidatingAdmissionPolicy. Native CEL admission is the right tool when you want no extra controller. Kyverno is the right tool when you also want reports, exceptions, background scans, and generate or image-verify rules. Running both without a written split produces two denies for one object and no owner.
Sentinel, Cedar, and Guard
Sentinel stays inside HashiCorp’s runner. The tutorial enforces a Name tag and an instance-type allowlist on EC2. The shape of the tag rule, from that tutorial:
mandatory_tags = [
"Name",
]
mandatory_instance_tags = rule {
all ec2_instances as _, instance {
all mandatory_tags as mt {
instance.change.after.tags contains mt
}
}
}
The tutorial also defines ec2_instances with a tfplan/v2 filter and a main rule that combines checks. Copy the tutorial, not this fragment, if you are about to test against mock-tfplan-v2.sentinel. Enforcement level is still set on the policy set, not in this file.
Cedar, from the syntax guide. This allows editPhoto only when the principal is the resource owner. It does not look at a Terraform plan. A matching forbid overrides any permit.
permit (
principal,
action == Action::"editPhoto",
resource
)
when {
resource.owner == principal
};
Use Cedar, or Verified Permissions, when you are building the service that decides whether a person or a pipeline identity may call apply. Use Rego or Guard when you are deciding whether the plan itself is acceptable.
Guard, from the project README. The rule skips itself when the template has no S3 buckets, then requires a name prefix and KMS encryption. Guard evaluates JSON and YAML. It does not parse HCL. The README says to pass a Terraform plan as JSON if you want Guard on Terraform.
let s3_buckets = Resources.*[ Type == /S3::Bucket/ ]
rule s3_bucket_name_encryption_check when %s3_buckets !empty {
%s3_buckets {
Properties {
BucketName == /^MyCompanyPrefix/
BucketEncryption.ServerSideEncryptionConfiguration[*] {
ServerSideEncryptionByDefault.SSEAlgorithm IN ["aws:KMS"]
}
}
}
}
Guard 3.2.2 is the current CLI. The README warns that Guard 2.0 and later break Guard 1.0 rules, and that 3.0 changed intrinsic-function handling in tests. If you are migrating old rules, use the migrate command documented there. Do not assume a 2021 rule still means the same thing.
Real scenarios
These are the situations the engines are built for. They are not anonymized incidents, and they are not customer metrics.
The plan CI never saw. A module gains an aws_security_group_rule with cidr_blocks = ["0.0.0.0/0"] on port 22. Reviewers looked at the root module. Conftest on terraform show -json sees resource_changes after module expansion. That is the correct gate. A comment in the contributing guide is not.
The tag finance asked for. owner, env, and cost-center are missing on create and update. The Rego above fails the plan. It will not fail a resource whose tags are computed at apply time. HashiCorp’s comparison page is the citation for that hole. Close it with a post-apply scan (Checkov against the cloud API, Guard against AWS Config items, or Azure Policy via EPAC), not by telling the plan policy to “try harder.”
The kubectl that skipped Git. A developer applies a privileged pod, or a pod with no owner label, from a workstation. CI did not run. Kyverno in Deny, or Gatekeeper, or GKE Policy Controller, is the gate that still runs, because it sits on the API server. Google’s Gatekeeper guide shows the shape: a constraint that rejects a container with securityContext.privileged set. Run it in dry-run or Audit until the report is boring.
The person, not the plan. A contractor’s pipeline identity can plan production and the plan is perfectly tagged. The missing control is authorization. Cedar’s permit / forbid model, or the cloud IAM you already have, answers that. Adding another tag check does not.
The override. Production is down, the policy is wrong, and someone needs to apply. Sentinel’s soft-mandatory level exists so an authorized override is an explicit act, logged, rather than a deleted policy file. Hard-mandatory means the only override is removing the policy. Pick that on purpose. The enforcement-level doc is the spec.
Enterprise real implementation example
Chase UK is the production deployment with a named engineer on a conference schedule, not only a vendor logo.
The session listing for KubeCon + CloudNativeCon Europe 2026, Audit-Ready Kubernetes: How Chase UK Leveraged Policy as Code for Continuous Compliance, names Jim Bugwadia (Nirmata) and Nischay Goyal (JP Morgan Chase). The abstract states that Chase UK’s cloud platform team uses Kyverno, OpenReports, and Grafana to enforce compliance as policy as code, that the solution is deployed in production, that the security team can write policies independently, and that compliance audit time dropped from weeks to minutes.
That is the claim set to trust as a conference abstract. It does not include cluster counts or a latency number.
Nirmata’s Chase UK case study is a vendor publication. Label it that way. It adds figures the schedule does not: about 50 clusters and 2,000 nodes; a start on OPA Gatekeeper that produced 4 policies; a later estate of 46 Kyverno policies; average admission latency under 20 ms; an estimated 7–8 months of engineering effort saved. It also describes the failure mode that made them move: Rego expertise was scarce, the people who had written the Gatekeeper policies had left, and there was no reporting, so developers did not own failing resources. Kyverno was chosen because policies are Kubernetes YAML and CRDs, reports exist, and Enforce, Audit, and Warn are modes rather than a rewrite. Those figures are Nirmata’s. They are not re-measured here.
The useful part for an infra team is the sequence, which matches the proposal above. They did not start by denying traffic. They replaced a manual audit and a small Rego island with a policy that ships as part of cluster build, reports into Grafana, and lets security open a pull request. The conference abstract’s “weeks to minutes” is the outcome that matters. The latency number is a vendor measurement of the admission webhook, not a promise that your cluster will see the same figure.
A second public record, on the OPA side, is Capital One in ADOPTERS.md: admission control for image registry allowlisting, labels, resources, and privileges, with a KubeCon US 2018 talk as the citation. Styra’s Capital One PDF is marketing on top of that. Use the adopters file and the talk if you need a primary source. Do not quote the PDF’s efficiency claims as measured results.
Nirmata also publishes a Robinhood case study describing a move off Pod Security Policies and an in-house admission server onto Kyverno, after OPA met the security requirements but Rego did not meet the team. That page is vendor-written. It is relevant as a named counterexample to “standardize on Rego everywhere,” not as an independent audit.
Next steps and recommendations
- Write down the last guardrail that failed in review or in an audit. One sentence, one resource type.
- Implement it as the Rego in this post, or as the Kyverno
ValidatingPolicyif the bypass path iskubectl. Runopa testor apply it inAudit. Do not install five products this week. - Wire Conftest to
terraform show -jsonon one repo, non-blocking. If you are already on HCP Terraform, a Terraform policy (HCL) or a Sentinel advisory policy set is the equivalent, and it will not cover Stacks if you pick Sentinel or OPA. That limit is in the enforcement overview. - After the failure list is mostly true positives, promote that one rule. Leave everything else advisory.
- Add the admission gate only for changes that never enter CI. Kyverno 1.20 or Gatekeeper 3.23.1, not both, unless you have written which object each owns.
- Put exceptions in Git with an owner and a date. A policy that cannot be excepted will be disabled.
- Pin the engine. OPA v1.22.4, Conftest v0.71.1, Kyverno chart 3.10.0, Checkov 3.4.5, Guard 3.2.2 are the snapshot in this post. They will move.
- Do not encode taste. “Must have a tag” and “must not be world-reachable” survive contact with other teams. “Must use this instance family” becomes a weekly argument unless finance owns the list.
- Separate the two questions in the platform backlog. Plan policy does not replace IAM. Cedar does not replace a plan policy.
- Keep the decision log. When an auditor asks what stopped the public bucket, the answer is a run URL or a policy report, not a memory of a review comment.
If the team is Kubernetes-only and will not learn Rego, start at Kyverno and stay there. If the team already standardizes on HCP Terraform, start in that policy set and add admission only for the kubectl hole. If you need one language across CI, Kubernetes, and a custom API, that language is Rego, and you still do not use it for human-to-human authorization if Cedar or your cloud IAM already answers that call.
The review comment can stay. It is how the rule gets written. It is not how the rule gets enforced.