We start with create New pipeline. To take a look at my pipelines visit my public Azure DevOps project: https://dev.azure.com/sergeydotnet/TerraformConfiguration/_build

Azure DevOps

Click on Pipelines-> Builds

New pipeline

Click on New Pipeline

Click on Use the visual designer

Select Source

Choose repo and branch where you created terraform configuration and click Continue

Choose Empty job.

Now specify a name and agent pool. I am using Hosted VS2017. This is agent provided be Azure DevOps, but limited free minutes. If you exceed the free limit you have to pay. You can of course use your own agents.

Click on + sign on Agent job 1

and start to write terraf... You get some Terraform task to choose from

Now we have a challenge which one to choose. I solved it quit easy. Go to marketplace, search for terraform


Unfortunately none of this task provided me full support I needed, but one of this taks was useful. It was Terraform task written by Charles Zipp because I can use it to install Terraform in my build pipeline. Details later.

Install this task

Terraform Build & Release Tasks

Click on Get it free


Click on Install


Click on Proceed to organization.

Now we can add this task to our pipeline.

Terraform Installer

Click on Add.

Update the version, at this moment the latest Terraform version is 0.11.11. Remember to Save your build pipeline.

Now we have to deal with our secrets. Remember we created terraform.tfvars file in this blog Create Azure Resource Group using Terraform.

Open Pipelines -> Library


Click on Secure files, then +Secure file

Upload file

Upload your terraform.tfvars file here


Click on OK

Now go back to your build pipeline


Click on Edit

Build Configuration

Click on + sign and in the Add task meny search for Download and choose Add for Download Secure File

Choose file to download, in our case terraform.tfvars

This file will be downloaded to the $(Agent.TempDirectory) directory and deleted when the build is over.

Now we have to copy this file to the place with other configuration files. Sounds strange but  it doesn't work if you call apply like this, just specify the path to terraform.tfvars file

terraform apply -var-file=$(Agent.TempDirectory)\terraform.tfvars -auto-approve

Anyway we add a new task Copy Files

Copy Files

Specify Source Folder and Target Folder

Copy Files

Don't worry about this strange syntax.


This is just predefined build variables Azure DevOps are using. The list of alle variables can you find here

Now add Command Line task

Command Line task

Specify Display name and Script to run

Terraform init
terraform init

Remember to Save your work


Add one more Command Line task

Terraform apply

Specify Display name and Script. Choose which secure files you want to use by setting --var-file=terraform.tfvars

terraform apply -var-file=terraform.tfvars -auto-approve

Now we have to remove the folder with our secrets files

Add new task Delete Files

Delete Files

Specify Display name, Source Folder and Contents


Now Save and queue the Build Pipeline

Logs looks like this


Now take a look to Azure Portal

Resource groups

MyVeryBestRG is created.

Now we have used the Azure DevOps visual designer.

Next blog post is going to be Using Terraform with Azure DevOps using YAML.

As Microsoft telling you with YAML you get  a better experience to configure your pipelines. Learn more about YAML here.

My public TerraformConfiguration project

Visual Studio Marketplace

Create Azure Resource Group using Terraform

Using Terraform with Azure DevOps using YAML

Microsoft YAML documentation