Utility Classes
Utility classes are reusable helpers that encapsulate common logic used across multiple Compliance Engine policies.
Why Use Utility Classes
Without utility classes, you might duplicate the same logic in many policies—for example:
- Enforcing a tagging standard across all compute, storage, and database resources.
- Checking a naming convention for multiple object types.
- Applying the same ownership or environment mapping logic in many controls.
By placing this logic in a utility class, you:
- Avoid copy‑and‑paste policy code.
- Make changes in one place when standards evolve.
- Reduce the chance of inconsistencies between similar controls.
Typical Pattern
A common example is a tagging utility:
- The utility class implements a method (for example, “check required tags”) that can be called from multiple policies.
- Each policy passes in the resource and required tags; the utility returns a result that the policy uses to decide compliance.
Other patterns include helpers for:
- Normalizing environment names.
- Resolving owners based on CMDB relationships.
- Reusing complex calculations or lookups across many policies.
Governance Considerations
Because utility classes can affect many policies:
- Treat them as shared libraries with clear ownership and change control.
- Review changes carefully, especially when they affect high‑impact controls.
- Document available utility methods so policy authors know when to reuse instead of reimplementing logic.