Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about policies/initiatives.json #1845

Open
sshockley opened this issue Nov 20, 2024 · 5 comments
Open

Question about policies/initiatives.json #1845

sshockley opened this issue Nov 20, 2024 · 5 comments
Labels
Area: Sovereign 👽 GH issues raised for sovereign clouds (US Gov, China) Type: Question / Feedback ❓👂 Further information is requested or just some feedback
Milestone

Comments

@sshockley
Copy link

Hi, I'm running into some issues deploying initiatives from eslzArm/managementGroupTemplates/policyDefinitions/policies.json and eslzArm/managementGroupTemplates/policyDefinitions/initiatives.json. Specifically, when I deploy the initiatives, I get messages like:
PolicyDefinitionNotFound
The policy set definition 'Enforce-Guardrails-BotService' request is invalid. The following policy definition could not be found: '/providers/Microsoft.Authorization/policyDefinitions/ad5621d6-a877-4407-aa93-a950b428315e'.

The full list of failures is:
Set / Policy not found
Enforce-EncryptTransit / 0e80e269-43a4-4ae9-b5bc-178126b8a5cb
Enforce-EncryptTransit_20240509 / 0e80e269-43a4-4ae9-b5bc-178126b8a5cb
Enforce-Guardrails-Automation / 6d02d2f7-e38b-4bdc-96f3-adc0a8726abc
Enforce-Guardrails-BotService / ad5621d6-a877-4407-aa93-a950b428315e
Enforce-Guardrails-ContainerApps / 8b346db6-85af-419b-8557-92cee2c0f9bb
Enforce-Guardrails-KeyVault / 86810a98-8e91-4a44-8386-ec66d0de5d57
Enforce-Guardrails-KeyVault-Sup / 84d327c3-164a-4685-b453-900478614456
Enforce-Guardrails-MachineLearning / e413671a-dd10-4cc1-a943-45b598596cb7
Enforce-Guardrails-MySQL / 3a58212a-c829-4f13-9872-6371df2fd0b4
Enforce-Guardrails-Network / 6484db87-a62d-4327-9f07-80a2cbdf333a
Enforce-Guardrails-Storage / 361c2074-3595-4e5d-8cab-4f21dffc835c

I should note this is in usgovvirginia.

I figured maybe there was a change upstream that hadn't been applied to this repo, so I tried rebuilding them:

az bicep build \
    --file ./src/templates/policies.bicep \
    --outfile ./eslzArm/managementGroupTemplates/policyDefinitions/policies.json
az bicep build \
    --file ./src/templates/initiatives.bicep \
    --outfile ./eslzArm/managementGroupTemplates/policyDefinitions/initiatives.json
az bicep build \
    --file ./src/templates/roles.bicep \
    --outfile ./eslzArm/managementGroupTemplates/roleDefinitions/customRoleDefinitions.json

After that, the only failure is Enforce-Guardrails-MachineLearning / e413671a-dd10-4cc1-a943-45b598596cb7 (policy defninition not found), but it does still fail.

So, finally getting around to my actual question, should the templates in eslzArm/managementGroupTemplates/policyDefinitions match the output of az bicep build? I note that the ARM templates have dire warnings about being programmatically generated, but looking at the commit history that isn't always the case.

@sshockley sshockley added the bug Something isn't working label Nov 20, 2024
@Springstone
Copy link
Member

@sshockley I'm not sure how you are going about this. You should be able to clone the repo and work from the main branch, as is and deploy the policies and initiatives (policies first of course) to a management group (do not recommend using the Tenant Root). You should not need to rebuild those files, that is a requirement prior to merging into this repo, so it should be current.

@Springstone Springstone added the Type: Question / Feedback ❓👂 Further information is requested or just some feedback label Nov 25, 2024
@Springstone
Copy link
Member

Just one point to note, the initiatives.json file REQUIRES a parameter to be provided (topLevelManagementGroupPrefix), which would be the intermediate root management group id. If you provide that as default value or a parameter, the deployment will work.

@Springstone
Copy link
Member

And I just noticed that you mentioned you're deploying to US Gov, which is currently not validated in this repo. We do have it on our backlog to remediate missing policies in the initiatives for US Gov / China.

@Springstone Springstone added the Area: Sovereign 👽 GH issues raised for sovereign clouds (US Gov, China) label Nov 25, 2024
@Springstone Springstone added this to the sovereign milestone Nov 25, 2024
@sshockley
Copy link
Author

Thanks for the info.

In general, I've been able to deploy by passing "" as topLevelManagementGroupPrefix, but maybe I've just been lucky. I do realize that ideally I shouldn't shoehorn this into an existing structure, but I'm working with what I have.

I guess my main question is if for example the output of az bicep build policies.bicep should always functionally match policies.json?

@Springstone
Copy link
Member

Yes, that is correct. The initiatives bicep build does require the topLevelManagementGroupPrefix as it is used in several initiatives.

@Springstone Springstone removed the bug Something isn't working label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Sovereign 👽 GH issues raised for sovereign clouds (US Gov, China) Type: Question / Feedback ❓👂 Further information is requested or just some feedback
Projects
None yet
Development

No branches or pull requests

2 participants