Skip to content

Structuring a Policy as Code Repo

Example only

Review and validate before production use. All values below are placeholders.

Goal

Create a repository structure that separates policy definitions, initiatives, assignments, and exemptions.

policy-as-code/
  definitions/
  initiatives/
  assignments/
  exemptions/
  pipelines/
  docs/

Design notes

  • Keep policy JSON files in definitions/ and version them clearly.
  • Bundle related definitions into initiatives in initiatives/.
  • Store environment-specific assignment parameters under assignments/.
  • Track temporary exemptions with expiry metadata in exemptions/.
  • Validate JSON and run deployment checks in pipelines/.

Minimal assignment example

{
  "name": "enforce-tag-owner",
  "scope": "/providers/Microsoft.Management/managementGroups/MG-PLACEHOLDER",
  "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/POLICY_ID_PLACEHOLDER",
  "parameters": {
    "tagName": {
      "value": "Owner"
    }
  }
}