Custom policy development
Plan the development workflow for a custom policy, from repository access and authoring through testing and maintenance.
Prepare the Development Environment
Start by defining the requirement, its rationale, and whether the available resource data can support an automated check. Prepare an editor, repo-manager, an authorization profile, and a BigQuery query tool for working with live data.
Follow Set up a development environment for tools and access prerequisites.
Choose a Repository
Use a private repository for organization-specific policies. Cloudaware can create and manage it through your Technical Account Manager (TAM), or your organization can manage its own repository and coordinate the service connection.
For a new repository, follow Set up a private policy repository. For an existing one, use Access the policy repository. Confirm the connected branch and activation process with your TAM before planning deployment.
Define Metadata and Logic
Create a policy directory under your organization's hierarchy in ce. Keep these elements together:
| Element | Purpose | Guide |
|---|---|---|
policy.yaml and folder descriptors | Identity, classification, and framework mappings | Structure a custom policy |
description.md and remediation.md | Rationale, audit instructions, and corrective steps | Name and document policies |
| Logic file | Input type, ordered conditions, fallback, and related-resource checks | Write policy logic |
Develop in wip.logic.yaml and use prod.logic.yaml when the implementation is ready for production. Preserve supporting research and explain important design decisions. If a requirement cannot be automated, document the limitation rather than implying an executable check exists.
Test, Review, and Maintain the Policy
Use the policy tools as needed during development:
| Command | Use |
|---|---|
repo-manager policies capture-test-data | Capture resource data for a policy's fixtures. |
repo-manager policies test | Validate logic against test fixtures. |
repo-manager policies generate | Generate BigQuery scripts for evaluation or debugging. |
repo-manager policies evaluate-object | Investigate a specific resource using a policy. |
Follow Test and debug policies for arguments, expected outcomes, and missing-data cases. Consult the repo-manager command reference for command details.
Review logic, documentation, and test results together before submitting changes through your team's Git workflow. Naming a file prod.logic.yaml identifies its intended role; confirm how the connected service receives and activates the change. See Deploy and maintain custom policies for upkeep and subsequent result checks.