Skip to main content

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:

ElementPurposeGuide
policy.yaml and folder descriptorsIdentity, classification, and framework mappingsStructure a custom policy
description.md and remediation.mdRationale, audit instructions, and corrective stepsName and document policies
Logic fileInput type, ordered conditions, fallback, and related-resource checksWrite 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:

CommandUse
repo-manager policies capture-test-dataCapture resource data for a policy's fixtures.
repo-manager policies testValidate logic against test fixtures.
repo-manager policies generateGenerate BigQuery scripts for evaluation or debugging.
repo-manager policies evaluate-objectInvestigate 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.