Skip to content

Build-DeploymentPlans -BuildExemptionsOnly fails on policydefinition that has been removed on a newer version of the initiative #1349

Description

Describe the bug
We have pinned the version of the "Microsoft Cloud Security Benchmark V2" policy initiative to version 1.3.*-preview in our policy assignment.

{
  "$schema": "https://raw.githubusercontent.com/Azure/enterprise-azure-policy-as-code/main/Schemas/policy-assignment-schema.json",
  "nodeName": "root/Deploy-MCSB2-Monitoring",
  "assignment": {
    "name": "Deploy-MCSB2-Monitoring",
    "displayName": "Microsoft Cloud Security Benchmark v2",
    "description": "Microsoft Cloud Security Benchmark v2 policy initiative."
  },
  "definitionEntry": {
    "displayName": "Microsoft Cloud Security Benchmark v2",
    "policySetId": "/providers/Microsoft.Authorization/policySetDefinitions/e3ec7e09-768c-4b64-882c-fcada3772047"
  },
  "definitionVersion": "1.3.*-preview",
  "enforcementMode": "Default",
  "parameters": {},
  "nonComplianceMessages": [
    {
      "message": "Microsoft Cloud Security Benchmark v2 must be met."
    }
  ],
  "scope": {
    "epac-dev": [
      "/providers/Microsoft.Management/managementGroups/epac-dev"
    ]
  }
}

Everything works fine. We have deployed it without issues and the reference is 1.3.*-preview in the portal.

This policy initiative has since been updated to 1.4.* (We are not ready to upgrade to 1.4.* yet)
In this 1.4.* version of the policy initiative the following definition has been removed:
remove Policy Configure Azure AI Services resources to disable local key access (disable local authentication) (55eff01b-f2bd-4c32-9203-db285f709d30)
But it still exist in version 1.3.*-preview

If we then go ahead and create an exemption on the Microsoft Cloud Security Benchmark V2 on that specific policy, the Build-DeploymentPlans fails as the policy reference does no longer exist (Even though we have set the version to 1.3.*-preview where the policy reference should exist). See screenshot below.

My thoughts are that it does not respect the pinned version we have assigned and instead plans against the latest version of the policy initiative.

To Reproduce

  1. Create an assignment on Microsoft Cloud Security Benchmark V2 with version pinned to 1.3.*-preview
  2. Create an exemption on the following policy: "Configure Azure AI Services resources to disable local key access (disable local authentication)"
  3. Execute command: Build-DeploymentPlans -PacEnvironmentSelector ${{ parameters.pacEnvironmentSelector }} -BuildExemptionsOnly -DevOpsType "ado" -InformationAction Continue
  4. Error

Expected behavior
Pipeline should succeed and exemption and plan show exemption to be created

Screenshots
Image

EPAC Version
Latest

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions