CMP-32Recommended
Keep roles as code
Define which job gets which role in a file in the repository, apply it from there, and change access only through a reviewed pull request.
How to do it
Write a role matrix that maps each job to its roles in each system. Apply it with infrastructure code, such as Terraform for the cloud and the code host. The pull request history then shows who asked for access, who approved it and when. The quarterly review reads the same matrix. Test every role against every action from the same file.
Examples
YAML example
support-agent:
admin-tool: [read-orders, refund-under-100]
helpdesk: [agent]
engineer:
code-host: [write]
cloud: [read-only]
database: []
How to check
A daily job compares the live roles in each system with the matrix and fails on any difference.
Sources
Related rules
- INF-18 Give every role the least it needs in Infrastructure and environments
- ACC-62 Map directory groups to roles in Accounts and identity
- ACC-36 Test every role and a signed-out visitor against every action in Accounts and identity
- DEN-28 Grant warehouse access by role from the directory in Data engineering
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/compliance/audit-logs-and-access/roles-as-code">Agent Wranglers compliance and governance playbook</a>. In code you write, add a comment next to it with the same link.