Use it when configuring, checking or troubleshooting Policy as Code in Automation Fundamentals.
Policy as Code · Automation Fundamentals
Policy as Code expresses governance, security or operational constraints in machine-testable definitions that can evaluate proposed or observed state consistently.
1. Policy as code expresses rules as testable code (OPA/Rego, Sentinel, Kyverno, Azure Policy).
2. Run in CI and admission.
3. Version and test policies.
4. Clear violation messages.
5. Exceptions as code.
change → policy evaluation → allow/deny with reason
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
policy intent → versioned rule/tests → normalized input → evaluation → decision/evidence → promotion → enforcement-point verification
Healthy evidence: policies are versioned and tested, decisions are attributable to inputs/version, exemptions are explicit and runtime enforcement matches policy intent.
Step 2 Failure modes and next checks Narrow the fault
Suspicious evidence: untested policies, stale enforcement versions, broad exemptions, inconsistent input normalization, policy passes in CI but runtime control is absent or bypassed.
Step 3 Common mistakes Narrow the fault
- Policies without tests or exceptions process.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Policy test pass ≠ runtime enforcement; the enforcement point may not use the tested policy/version.
- Policy as code ≠ desired infrastructure state; it constrains or evaluates state rather than necessarily creating it.
- Deny result ≠ root cause; input normalization, exemptions and policy selection must be traceable.
- Policy in Git ≠ active policy automatically; promotion/deployment and enforcement linkage are separate boundaries.
opa eval -d policy.rego -i input.json 'data.main.deny'— OPA policy testconftest test manifest.yaml— policy check on filescheckov -d .— IaC policy scan
ReferenceWhat it is1 section · depth on demand
Core model
Version policy and test cases, evaluate normalized input or plan data, return explicit allow/deny/advisory findings, bind enforcement points to policy versions and verify runtime behavior where policy is meant to control execution.
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
A policy evaluation shows what a specific policy version decided for specific input, but it does not show that decision was enforced at runtime.
In depth
Policy as code turns rules — security requirements, naming standards, compliance controls — into code that tools evaluate automatically. A pipeline can then block a Terraform plan that opens SSH to the internet, or a scheduled job can report switches without BPDU Guard on access ports, without anyone checking manually.
| Where policies run | Example |
|---|---|
| Before change (CI) | Conftest on Terraform plans, Batfish on configs |
| At admission | Kyverno/Gatekeeper in Kubernetes |
| Continuously | Cloud policies, compliance scans |
Treat policies like software: version them, test them with examples that should pass and fail, document exceptions explicitly, and start in audit mode before enforcing.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Automation Fundamentals > Policy as Code. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/azure/well-architected/operational-excellence/enable-automation · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Policy as Code automation boundary map
Fast intent, state, execution, verification and recovery boundaries for Policy as Code.
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Intent / inputs | Owner, scope and authoritative inputs are explicit and versioned where applicable | Hidden defaults, stale inventory or competing sources of truth |
| Decision / execution | Plan or decision is explainable and actions are bounded per target | Blind fan-out, implicit assumptions or success based only on executor status |
| State / verification | Target is re-observed and acceptance criteria prove the intended outcome | No read-back, perpetual drift, partial side effects or unresolved exceptions |
| Recovery / evidence | Retry, rollback or escalation behavior is defined and auditable | Unknown partial completion, unsafe retry or evidence lost during remediation |