Policy as code
Scan infrastructure code on every change, test your own rules against the plan, block dangerous actions at the organization level, and let exceptions expire.
- Recommended 5
Policy as code turns infrastructure rules into checks that pass or fail. Some checks run on the code before anything changes. Others sit in the cloud and refuse a call even from an admin. Together they catch the mistakes a review misses. They follow the rules as code idea from the engineering playbook.
Recommended
Scan infrastructure code on every change
INF-38Run an infrastructure scanner on every pull request, and fail the build on any finding rated high or critical.
Test your own rules against the plan
INF-39Write the house rules that no scanner knows as policies, and run them against the plan in CI. Examples are the allowed regions, the required tags and the largest server size.
Block dangerous actions for the whole organization
INF-40Set organization-wide policies that refuse the most dangerous actions in every account, even for admins.
Let every exception expire
INF-41Give every skipped check a reason, an owner and an end date in the code. Fail the build once the date has passed.
Test infrastructure modules
INF-42Give every shared module tests that check its plan, and run them in CI on every change to the module.
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/infrastructure/policy-as-code">Agent Wranglers infrastructure and environments playbook</a>. In code you write, add a comment next to it with the same link.