@Logan Thank you for reaching out to us and appreciate your patience during the support tenure through Microsoft Q&A platform.Sharing the summarized answer to help other community members/users looking for similar solution.
Question: Allow deployments only from Terraform using Azure Policy
Solution: You could leverage identity-based exemptions, which is currently in private preview, to achieve this scenario. With this, you’d be able to apply a policy to prevent resource creation or modification, then create an exemption for that assignment which would allow the Terraform pipeline’s Service Principal ID to bypass the policy.
So, you’ll first need to create the policy definition which blocks storage account creation, then assign it to the desired scope. Once that assignment is in place, then you’ll create an exemption for that assignment which uses selectors to specify allowed/disallowed user/object ID(s).
Also, in your selectors, it is not necessary to use both the “in” and “notIn” restrictions – this one is more restrictive and can be used by itself: "kind": "userPrincipalId
", "in": ["1234-1234"]
[create block all users E.g group1 and create exemption for specific users
] is the correct understanding. In its current private preview state, identity-based exemptions through resource selectors are not supported in portal. Try creating the exemption through an API call.
You should be able to create the exemption using an API request URI & request body like this (be sure to first assign the policy, then insert real values for the placeholders shown):
Note: The feature is fully supported at the API level but remains in private preview while we collect feedback on the experience and complete the necessary steps to release it in public preview or GA, including portal support. We don’t currently have an ETA for these releases, but we will be reaching out to customers using the private preview to keep you informed, and you can keep up with product announcements through blog posts.
If the response helped, do "Accept Answer" and up-vote it