Manage Azure DevOps organization with Terraform 1/3: The provider configuration

I have been using Terraform for Azure for almost 2 years now and some time ago I wondered why not use Terraform to manage my Azure DevOps organization.
One of the elements that motivated me the most is that I always encounter the same problem with customers who use Azure DevOps is the fact that they often want to automate the creation of projects, build/release, feed, boards,… but also to have a certain governance of coherence between projects such as nomenclatures, permissions, build/release tasks,…

And so…., after reflection I decided to create a Terraform provider for Azure DevOps.

First, I had to initiate a SDK in Go (available in my GitHub) of Azure DevOps Api Rest, and to go faster in this development I used Azure’s autorest tool which allows to generate a SDK (in many languages) from swagger specification Json file.

After a few months of work, I was finally able to deliver a 1st version of this Terraform provider for Azure DevOps and I would now like to share with you its use in several articles.

Actually, in this first version of this provider, we can manage projects and Build definitions.

In this first article of this series, I will expose how to install the provider and how configure it to connect and authenticate it with Azure DevOps.

Requirements

For use this provider, we need some requirements:

  • Have an Azure DevOps organization, , see the documentation for create it for free.
  • Generate a PAT (Personal Access Token) for authentication, see the documentation.

Download and Install the Azure DevOps provider

For download the provider go to the release page , download the appropriate zip of your OS.

After downloaded the zip , extract it and copy it in the terraform plugins folder on your machine.
For Windows , copy it into the %APPDATA%\terraform.d\plugins local folder, for other system copy it into ~/.terraform.d/plugins local folder.

Configure and use the provider

In your Terraform files (.tf) we need to configure the azuredevops provider with the organization and the PAT.

provider "azuredevops" {  
organization = "<name of your Azure DevOps organisation>"
token = "<Your PAT authentication>"
}

That is the basic configuration of the provider. 
For don’t keep this sensitive information in your code you can use environment variables instead with leave the provider configuration empty:

provider "azuredevops" {}

And use the AZURE_DEVOPS_ORGANIZATION environment variable for the name of the organization, and the AZURE_DEVOPS_TOKEN environment variable for the PAT.

That all for the Azure DevOps Terraform provider configuration.

In the next article, we will see how manage Azure DevOps project in Organization with Terraform.

Resources: