Azure / enterprise-azure-policy-as-code

Enterprise-ready Azure Policy-as-Code (PaC) solution (includes Az DevOps pipeline)
https://azure.github.io/enterprise-azure-policy-as-code/
MIT License
437 stars 243 forks source link

policyGroupName logic is reversed #676

Closed luke-iseger91 closed 5 months ago

luke-iseger91 commented 5 months ago

Describe the bug If you define a policyGroupName in a policyset, but never use it in one of the policyDefinitions in the set, EPAC throws an error that the policyDefinitionGroup is not found. This is likely caused by a change in v10.3.2, which added an extra error check in Build-PolicySetPlan.ps1.

I think the logic here needs to be slightly reversed. Rather then checking if $usedPolicyGroupDefinitions.ContainsKey($groupName), where $groupName comes from the loop on $policyDefinitionGroups . It should be something like $policyDefinitionGroups.ContainsKey($groupName) where $groupName comes from the loop on $usedPolicyGroupDefinitions.

To Reproduce

Expected behavior The set should deploy. Empty groups are allowed in Azure.

Screenshots epac-groups

EPAC Version V10.3.2 and above

anwather commented 5 months ago

Thanks - I've got a PR open for this - should be fixed tomorrow.

flaviomeyer commented 5 months ago

Thanks @luke-iseger91 I have just encountered the same problem.

Thanks for the quick fix @anwather

anwather commented 5 months ago

The PR is in our development environment waiting approval should be published tomorrow.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Meyer Flavio @.> Sent: Tuesday, June 18, 2024 9:23:16 PM To: Azure/enterprise-azure-policy-as-code @.> Cc: Mention @.>; Comment @.>; Assign @.>; Subscribed @.> Subject: Re: [Azure/enterprise-azure-policy-as-code] policyGroupName logic is reversed (Issue #676)

Thanks @luke-iseger91https://github.com/luke-iseger91 I have just encountered the same problem.

Thanks for the quick fix @anwatherhttps://github.com/anwather

— Reply to this email directly, view it on GitHubhttps://github.com/Azure/enterprise-azure-policy-as-code/issues/676#issuecomment-2175861043 or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACWCJVXL7VJ3JGDOWAAFACDZIAKCJBFKMF2HI4TJMJ2XIZLTSSBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLAVFOZQWY5LFVIZDOMRVHE4DSNBXHCSG4YLNMWUWQYLTL5WGCYTFNSWHG5LCNJSWG5C7OR4XAZNMJFZXG5LFINXW23LFNZ2KM5DPOBUWG44TQKSHI6LQMWVHEZLQN5ZWS5DPOJ42K5TBNR2WLKJTGM3TCNRSHAZTRAVEOR4XAZNFNFZXG5LFUV3GC3DVMWVDEMZVG42TCMJSGMZIFJDUPFYGLJLMMFRGK3FFOZQWY5LFVIZDOMRVHE4DSNBXHCTXI4TJM5TWK4VGMNZGKYLUMU. You are receiving this email because you were mentioned.

Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.