Allow deployments only from Terraform using Azure Policy

Logan 0 Reputation points
2025-03-26T14:00:40.9233333+00:00

Hi Team,

Is it possible to block all deployments and allow it only from Terraform? I tried this but it didn't work.

{
          "not": {
            "anyOf": [
              {
                "field": "Microsoft.Authorization/roleAssignments/principalId",
                "equals": "[parameters('allowedServicePrincipal')]"
              }
            ]
          }
        }
Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
992 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.