liveBook · Manning

Policy as code

As explained in Grokking Software Architecture

Policy as code is the representation and automated enforcement of operational or security rules in machine-readable code.

Policy as code turns security rules into machine-readable checks that run automatically. In a CI/CD pipeline, an unsafe infrastructure change can fail the build before reaching production. section 11.7.1

Reject an unsafe network route

If a Terraform change connects a vendor subnet to a highly secure Point of Sale subnet, policy checks can fail the build. Teams can also unit-test the policies by simulating an attacker trying to breach a subnet. section 11.7.1

How Grokking Software Architecture covers it

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.
How it connects
Links policy as code with infrastructure as code, Terraform, CI/CD, Open Policy Agent, and static application security testing.

Also explained in

Compare how 5 books explain policy as code →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.