How to enforce IaC in production? are there some references of custom policies that accepts only deployments made by service principles?

SrVish 20 Reputation points
2025-04-02T20:43:10.47+00:00

I am learning about enforcing IaC in our cloud environments and I am looking for some best practices and references on this.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,368 questions
0 comments No comments
{count} votes

Accepted answer
  1. Stanislav Zhelyazkov 28,426 Reputation points MVP Volunteer Moderator
    2025-04-03T05:34:24.2766667+00:00

    Hi,

    Enforcing deployments only by service principals it is not possible. The only way to semi-achieve this is by giving appropriate permissions to deploy/create resources to service principals only and for all other accounts to give only reader permissions. In case some actions needs to be done by users you can use Entra PIM to allow access temporary. That is usually a standard practice. If you want to limit the access to resources deployed by IaC I would suggest to look at Azure Bicep and deployment stacks. Deployment stacks allows for locking the resources so they cannot be modified outside of the deployment stacks deployment. Alternatively you can look at Azure Policy deny action as a way to protect resources.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


0 additional answers

Sort by: Most helpful

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.