microsoft/terraform-provider-azuredevops
Go
Captured source
source ↗microsoft/terraform-provider-azuredevops
Description: Terraform Azure DevOps provider
Language: Go
License: MIT
Stars: 427
Forks: 312
Open issues: 212
Created: 2020-06-18T13:22:32Z
Pushed: 2026-06-25T04:30:21Z
Default branch: main
Fork: no
Archived: no
README:
Terraform Provider for Azure DevOps (Devops Resource Manager)
 
The AzureRM Provider supports Terraform 0.12.x and later.
- Terraform Website
- Azure DevOps Website
- [Provider Documentation](./website/docs/index.html.markdown)
- [Resources Documentation](./website/docs/r/)
- [Data Sources Documentation](./website/docs/d/)
- [Usage Examples](./examples/)
- Gitter Channel
Usage Example
# Make sure to set the following environment variables:
# AZDO_PERSONAL_ACCESS_TOKEN
# AZDO_ORG_SERVICE_URL
terraform {
required_providers {
azuredevops = {
source = "microsoft/azuredevops"
version = ">=0.1.0"
}
}
}
resource "azuredevops_project" "project" {
name = "My Awesome Project"
description = "All of my awesomee things"
}
resource "azuredevops_git_repository" "repository" {
project_id = azuredevops_project.project.id
name = "My Awesome Repo"
initialization {
init_type = "Clean"
}
}
resource "azuredevops_build_definition" "build_definition" {
project_id = azuredevops_project.project.id
name = "My Awesome Build Pipeline"
path = "\\"
repository {
repo_type = "TfsGit"
repo_id = azuredevops_git_repository.repository.id
branch_name = azuredevops_git_repository.repository.default_branch
yml_path = "azure-pipelines.yml"
}
}Developer Requirements
If you're on Windows you'll also need:
If you want to use the makefile build strategy on Windows it's required to install
For *GNU32 Make*, make sure its bin path is added to PATH environment variable.*
For *Git Bash for Windows*, at the step of "Adjusting your PATH environment", please choose "Use Git and optional Unix tools from Windows Command Prompt".*
As [described below](#build-using-powerShell-scripts) we provide some PowerShell scripts to build the provider on Windows, without the requiremet to install any Unix based tools aside Go.
Developing the Provider
If you wish to work on the provider, you'll first need Go installed on your machine (version 1.16+ is required). You'll also need to correctly setup a GOPATH, as well as adding $GOPATH/bin to your $PATH.
Using the GOPATH model
First clone the repository to: $GOPATH/src/github.com/microsoft/terraform-provider-azuredevops
$ mkdir -p $GOPATH/src/github.com/terraform-providers && cd "$_" $ git clone git@github.com:microsoft/terraform-provider-azuredevops.git $ cd terraform-provider-azuredevops
Once you've cloned, run the ./scripts/build.sh and ./scripts/local-install.sh, as recommended here. These commands will sideload the plugin for Terraform.
Using a directory separate from GOPATH
The infrastructure supports building and testing the provider outside GOPATH in an arbitrary directory. In this scenario all required packages of the provider during build will be managed via the pkg in $GOPATH. As with the [GOPATH Model](#using-the-gopath-model), you can redefine the GOPATH environment variable to prevent existing packages in the current GOPATH directory from being changed.
Build using make
Once inside the provider directory, you can run make tools to install the dependent tooling required to compile the provider.
At this point you can compile the provider by running make build, which will build the provider and put the provider binary in the $GOPATH/bin directory.
$ make build ... $ $GOPATH/bin/terraform-provider-azuredevops ...
You can also cross-compile if necessary:
GOOS=windows GOARCH=amd64 make build
Unit tests
In order to run the Unit Tests for the provider, you can run:
$ make test
With VSCode Golang extension you can also run and debug the tests using run test, debug test run package tests, run file tests buttons.
Acceptance tests
The majority of tests in the provider are acceptance tests - which provisions real resources in Azure Devops and Azure. To run any acceptance tests you need to set AZDO_ORG_SERVICE_URL, AZDO_PERSONAL_ACCESS_TOKEN environment variables, some test have additional environment variables required to run. You can find out the required environment variables by running the test. Most of these variables can be set to dummy values.
The several options to run the tests are:
- Run the entire acceptance test suite
make testacc
- Run a subset using a prefix
make testacc TESTARGS='-run=TestAccBuildDefinitionBitbucket_Create' TESTTAGS='resource_build_definition'
- With VSCode Golang extension you can also run the tests using
run test,run package tests,run file testsbuttons above the test
Scaffolding the Website Documentation
You can scaffold the documentation for a Data Source by running:
$ make scaffold-website BRAND_NAME="Agent Pool" RESOURCE_NAME="azuredevops_agent_pool" RESOURCE_TYPE="data"
You can scaffold the documentation for a Resource by running:
$ make scaffold-website BRAND_NAME="Agent Pool" RESOURCE_NAME="azuredevops_agent_pool" RESOURCE_TYPE="resource" RESOURCE_ID="00000000-0000-0000-0000-000000000000"
> > BRAND_NAME is the human readable name of the object that is handled by a > Terraform resource or datasource, like Agent Pool, User Entitlement or Kubernetes Service Endpoint >
###...
Excerpt shown — open the source for the full document.
Notability
notability 5.0/10Solid new Terraform provider for Azure DevOps