1
votes

I'm trying to create Azure virtual machine with Terraform and Azure Devops. I'm getting below error.
"The directory /home/vsts/work/1/s contains no Terraform configuration files." Below is my .yml file.

resources:
- repo: self
steps:
- task: TerraformInstaller@0
  inputs:
    terraformVersion: '0.12.3'
- task: TerraformTaskV1@0
  displayName: 'Init terraform'
  inputs:
      provider: 'azurerm'
      command: 'init'
      backendServiceArm: 'Free Trial'
      backendAzureRmResourceGroupName: 'terraformtest-rg'
      backendAzureRmStorageAccountName: 'terraformtestrgdiag'
      backendAzureRmContainerName: 'bootdiagnostics-terraform'
      backendAzureRmKey: 'terraform'
- task: TerraformTaskV1@0
  displayName: 'apply status'
  inputs:
      terraformFile: './terraform/terra/main2.tf'
      provider: 'azurerm'
      command: 'apply'
      environmentServiceNameAzureRM: 'Free Trial ()'
1
I suspect you need to add terraformFile: './terraform/terra/main2.tf' to the first tf step?4c74356b41

1 Answers

0
votes

The directory /home/vsts/work/1/s contains no Terraform configuration files. In Azure Devops trying to create Azure resource

According to the error:

the directory /home/vsts/work/1/s contains no Terraform configuration files

It seems you have run the command in the wrong folder. You have to be in the directory that contains your configuration files before running init.

So, you could add the arguments like workingDirectory in the first task TerraformTaskV1, like:

workingDirectory: '$(System.DefaultWorkingDirectory)\terraform\terra'

Hope this helps.