azureazure-devopsterraform

Azure DevOps agent pool creating using Terraform


I need to create Azure DevOps agent pool using Terraform.

In Terraform I'm using microsoft/azuredevops provider. And resource azuredevops_agent_pool

In conclusion, I have an error Error creating agent pool in Azure DevOps: Access denied. user needs Manage permissions to perform the action. For more information, contact the Azure DevOps Server administrator.

I have Administrator permissions in Azure Devops. What can I try with this error?

UPD. I can create agent pool from Web UI azuredevops. I am using authentication with PAT. PAT configured for FULL access.

UPD2. I understood that access on Project Level is other than access on Organization Level. So I have full access on Project Level but terraform is trying to create agent pull on Organization Level.


Solution

  • It's not possible at the moment. I face the same issue. The issue is still opened since 2020. https://github.com/Azure/terraform-azurerm-aci-devops-agent/issues/4

    As mentioned on the README.md

    Before running this module, you need to create an agent pool in your Azure DevOps organization and a personal access token that it authorized to manage this agent pool.

    So it's not possible to automatically create an agent pool from the official Terraform azure DevOps provider

    You might try to find a way through Azure DevOPS REST API: https://learn.microsoft.com/en-us/rest/api/azure/devops/distributedtask/elasticpools/create?view=azure-devops-rest-7.1

    You might also find this GitHub issue comment useful: https://github.com/microsoft/terraform-provider-azuredevops/issues/204#issuecomment-962504540 Someone has already developed a way to do with Terraform using local-exec combined with azure cli/PowerShell/rest api