Structure a custom policy
Organize policy files, metadata, documentation, and test data in a policy repository.
Repository Layout and Descriptors
Place custom policies under ce/{yourOrg}. Grouping directories require folder.yaml; a policy directory requires policy.yaml. See Repository Structure for the full layout.
Example policy directory:
ce/my-company/aws/account/support-access/
policy.yaml
description.md
remediation.md
wip.logic.yaml
test-data.json
Policy Identifiers and Metadata
The directory determines the policy ID: /ce/my-company/aws/account/support-access in this example. Renaming or moving it changes the identifier.
policy.yaml supplies display names, summary, type, categories, and optional mappings or tags. Keep detailed field definitions in Policy files and YAML schema.
Description and Remediation Files
Use description.md for rationale, impact, audit procedures, and references; use remediation.md for corrective steps. Keep supporting research alongside the policy. Follow Name and document policies.
Logic and Test Fixture Placement
Develop in wip.logic.yaml; prod.logic.yaml identifies production logic. Place fixtures alongside the descriptor and reference them from logic:
testData:
- file: test-data.json
Fixtures supply expected outcomes, evaluation context, and resource fields. See Write policy logic and Test and debug policies.
Minimal Policy File Example
The built-in AWS Support Role policy uses type COMPLIANCE_POLICY and category SECURITY. The following illustrative custom descriptor uses those classifications with organization-specific names and a summary; it is not a copy of the built-in policy.
names:
contextual: Support access does not meet company requirements
full: AWS Account support access does not meet company requirements
description: Checks whether account support access meets the company's documented requirements.
type: COMPLIANCE_POLICY
categories:
- SECURITY
Save this as policy.yaml in the example directory. In a grouping directory such as ce/my-company/aws/account, use a separate folder.yaml:
names:
contextual: Account
full: Company AWS Account Policies
The descriptor documents intent; add and test logic to implement the check. Compare the complete built-in example in Read policy details. Validate your files against the repository's current schemas before use.