Policy as code
Policy as code is the practice of expressing organizational, security, authorization, or compliance policies as machine-readable, version-controlled rules that can be tested and enforced automatically.
Authorization in Action
Policy as code is an approach that represents policy as machine-readable, version-controlled, and testable software artifacts.
- How it is used
- Uses machine-readable rules to externalize access logic and support runtime, context-aware authorization decisions.
- How deep it goes
- Explains policy design, repository-to-store deployment, testing, static analysis, and rollback, while deferring fuller governance treatment.
- Examples
- Illustrates device-security restrictions, department-based access, and separate collaboration, deployment, and global guardrail policy repositories.
- What you can do after
- Operate and configure an authorization policy lifecycle using repositories, automated tests, signed bundles, runtime stores, and rollback.
Architecting for Autonomy
Policy-as-code is a technique that represents authorization and governance policies in executable machine-readable form.
- How it is used
- Applies runtime governance to autonomous agent actions rather than relying only on design-time approvals.
- How deep it goes
- Defines executable governance rules and illustrates pre-execution evaluation, escalation, and policy-engine failure handling.
- Examples
- Illustrates authorization of outbound communications and a clinical policy for elective-surgery deferrals.
- What you can do after
- Evaluate and understand how executable rules constrain agent actions and specify escalation or fallback.
Read how Architecting for Autonomy explains policy as code →
Effective Platform Engineering
Policy-as-code is the practice of representing organizational policies as machine-readable code that can be evaluated and enforced automatically.
- How it is used
- Enforces governance and trust requirements at platform boundaries without taking development orchestration away from teams.
- How deep it goes
- Explains enforcement placements and implementation trade-offs, including admission controllers and service-mesh checks, without detailing a complete policy implementation.
- Examples
- Uses required Kubernetes deployment labels, signed software artifacts, and service-mesh authorization checks as operational examples.
- What you can do after
- Apply it via Gatekeeper or OPA to place compliance or authorization checks at deployment and service-access boundaries.
Read how Effective Platform Engineering explains policy as code →
Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform
Policy as code is the practice of expressing security and compliance rules in executable or declarative form so infrastructure changes can be evaluated automatically.
- How it is used
- Gates infrastructure changes with automated security and compliance checks before production.
- How deep it goes
- Explains metadata parsing, field assertions, enforcement categories, reuse, and failure handling without detailing policy-engine internals.
- Examples
- Uses a Python pytest check that rejects GCP 0.0.0.0/0 database access and maps the pattern to AWS and Azure firewall resources.
- What you can do after
- Build and operate preproduction policy checks that diagnose insecure metadata and block noncompliant infrastructure changes.
Grokking Software Architecture
Policy as code is the representation and automated enforcement of operational or security rules in machine-readable code.
- How it is used
- Enforces security boundaries automatically in CI/CD before infrastructure changes reach production.
- How deep it goes
- Connects policy-as-code and infrastructure scanning to build failures and policy unit tests, but gives no policy syntax.
- Examples
- Uses a Terraform route between vendor and Point of Sale subnets as a rejected change, then tests guardrails with a mock attacker.
- What you can do after
- Apply it via Open Policy Agent and infrastructure-as-code scanners to reject unsafe Terraform network routes before deployment.
Read how Grokking Software Architecture explains policy as code →
Also covered in
- Vibe EngineeringIn early access (MEAP)
- Google Anthos in Action
What to know first
- auditabilityAuditability is the extent to which a system or process can be examined and its actions, decisions, data, and changes verified from available evidence.
- complianceCompliance is conformity with applicable legal, regulatory, contractual, policy, or other governing requirements.
- AI agentAn AI agent is a computational system that uses artificial intelligence to interpret information and select or perform actions toward goals while interacting with an environment.
- anomaly detectionAnomaly detection is the identification of observations, events, or behaviors that substantially deviate from expected patterns or a normal baseline.
Related concepts
- deployment pipelineuses · A deployment pipeline is a repeatable sequence of stages that builds, tests or validates, packages, and delivers software changes toward release or deployment.
- policy as datacontrasts with · An authorization approach that stores specific attributes, permissions, or relationships as structured data for a general-purpose engine to evaluate at runtime.
- policy languageuses · A policy language is a formal language for expressing rules governing permissions, actions, authorization, or resource access.
- software testinguses · Software testing is the systematic evaluation of software under specified inputs or conditions to assess its behavior against expected results or requirements and identify defects.
- versioninguses · Versioning is the practice of assigning or maintaining identifiable revisions of artifacts over time so their changes, histories, or compatibility can be tracked.
- policy engineuses · A policy engine is a software component that evaluates policies against requests, resources, actions, or other inputs and produces decisions or enforcement outcomes.
Questions about policy as code
What is policy as code?
Policy as code is the practice of expressing organizational, security, authorization, or compliance policies as machine-readable, version-controlled rules that can be tested and enforced automatically.
Which Manning books explain policy as code?
Authorization in Action, Architecting for Autonomy, Effective Platform Engineering, Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform and Grokking Software Architecture.
What should I know before learning policy as code?
Manning books that teach policy as code usually introduce auditability, compliance, AI agent and anomaly detection first.
What is the difference between policy as code and policy as data?
Policy as code is the practice of expressing organizational, security, authorization, or compliance policies as machine-readable, version-controlled rules that can be tested and enforced automatically. An authorization approach that stores specific attributes, permissions, or relationships as structured data for a general-purpose engine to evaluate at runtime.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




