Policy files and YAML schema
Look up policy repository files, YAML fields, identifier conventions, and test fixture structure.
This reference summarizes common file shapes. Validate required fields and supported values against your repository's current schemas. For directory navigation, see Repository Structure.
Folder and Policy Descriptors
| File | Role |
|---|---|
folder.yaml | Groups policies; supplies names.full and names.contextual. |
policy.yaml | Identifies a policy and its metadata. |
section.yaml | Describes a framework section. |
Grouping directories under ce use folder descriptors; policy directories use policy descriptors.
Policy Metadata and Identifiers
| Field | Purpose |
|---|---|
names.full, names.contextual | Standalone and hierarchical labels |
description | Plain-text summary |
type | COMPLIANCE_POLICY or BEST_PRACTICE |
categories | SECURITY, RELIABILITY, PERFORMANCE, COST |
frameworkMappings | Direct section associations |
frameworkIgnoreMappings | Exclusions from indirect mappings |
similarPolicies | Related vendor rules or policies |
tags | Custom classification |
impossible | Technically unenforceable requirement marker |
A policy ID identifies its directory; a logic ID includes the filename. For example, /ce/ca/aws/account/aws-support-role and /ce/ca/aws/account/aws-support-role/prod.logic.yaml identify different entities.
Logic Files and Fields
| Field | Requirement | Purpose |
|---|---|---|
inputType | Required | CMDB type API name |
conditions | Required | Ordered checks |
otherwise | Required | Fallback outcome |
recordTypes | Optional | Record type restriction |
testData | Optional | Fixture references |
importExtracts | Optional | Extract imports |
relatedLists | Optional | Related-object checks |
In the support-role implementation, inputType is CA10__CaAwsAccount__c. Each condition combines a check, status, and currentStateMessage; violation conditions also provide remediationMessage. Related lists select records through relationshipName and contain their own conditions and fallback.
The production example uses these fixture references:
testData:
- file: test-data.json
prod.logic.yaml is the production implementation; wip.logic.yaml is used during development. See Write policy logic for a complete worked adaptation.
Extract Definitions
Extract files reside under types/{type}/{name}.extracts.yaml. Their extracts list gives each value a name and an operation under value.
This shortened IAM policy extract illustrates field access and an explicit empty-value diagnostic:
extracts:
- name: CA10__arn__c
value:
FIELD:
path: CA10__arn__c
undeterminedIf:
isEmpty: The policy ARN is unavailable.
Import the existing file in logic evaluated against that type:
importExtracts:
- file: /types/CA10__CaAwsIamPolicy__c/object.extracts.yaml
Use EXTRACT: CA10__arn__c within an expression to retrieve the named value. The built-in support-role check imports this file within its IAM policy related list and compares the result with arn:aws:iam::aws:policy/AWSSupportAccess.
Test Fixture Structure
test-data.json is an array of test objects. Each object combines expected results, evaluation context, and resource fields:
| Element | Contents |
|---|---|
expectedResult.status | Expected resource outcome |
expectedResult.conditionIndex | Expected deciding condition index |
expectedResult.conditionText | Expected condition representation |
expectedResult.runtimeError | Expected error or null |
context.snapshotTime | Timestamp for time-dependent checks |
| Resource fields and relationships | Inputs needed by the logic |
The support-role fixture includes account records with nested IAM policy and attachment lists. Keep those relationships consistent with the selected input type. For fixture preparation and comparisons, follow Test and debug policies.
Minimal File Examples
An illustrative custom policy.yaml, using the support-role example's classification:
names:
full: Company AWS Account support access is not configured
contextual: Support access is not configured
description: Checks account support access against company requirements.
type: COMPLIANCE_POLICY
categories:
- SECURITY
A grouping directory's folder.yaml supplies its own labels:
names:
full: Company AWS Account Policies
contextual: Account
These descriptors do not implement the requirement. Add logic, documentation, and fixtures using Structure a custom policy, then validate and test the files with your supported tooling.