Azure Policy and Azure Dev Test using Terraform technical question

Charlie Cobre 1 Reputation point
2022-02-28T00:02:05.33+00:00

Hi All,

We are trying to deploy Azure DevTest Lab on our client's Azure subscription using terraform. and we wanted to use Azure policy to avoid deploying VM with the same VM name.
Can this be achieve using terraform variables file and how can we incorporate Azure Policy to the terraform code to achieve this outcome?

Regards,

Charlie Cobre

Azure DevTest Labs
Azure DevTest Labs
An Azure service that is used for provisioning development and test environments.
267 questions
Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
836 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AnuragSingh-MSFT 21,246 Reputation points
    2022-03-08T13:43:22.843+00:00

    Hi @Charlie Cobre ,

    Welcome to Microsoft Q&A! Apologies for the delayed response.

    With Azure Policy itself, there is no way to restrict the creation of a VM with same name in a Resource Group. However, the VM name must be unique in a single Resource Group, i.e., the names of resources must be unique in a resource group. If you are looking for a solution to avoid same name VMs at a Resource Group level, there is no need to configure anything extra as such VM creation request would fail anyway.

    Regarding Terraform question, I would request you to post the query to Terraform community for help.

    Please let me know if you have any questions.

    ---
    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.